Closed mbunk closed 3 months ago
Hi,
And thanks for reporting the issue with a reproducible example. I don't think it really is a questionr
issue: quantreg
is not used directly by questionr
, it is called by ggplot2
. And it is in the Suggests
dependencies of ggplot2
, which means it won't be installed by default. So I think the correct way to handle this is the way you did, by installing it manually when it was requested.
Thanks !
Thanks for the quick response!
That makes sense. I wanted to flag because I found it peculiar that my boxplots without survey weighting adjustments render fine from ggplot2
before loading quantreg
,
e.g.
ggplot(d) + aes(y = Freq, x = Survived) + geom_boxplot()
but the difficulty emerges with the questionr
version. Works well once quantreg
is loaded, so I will close the issue.
Thanks again!
In fact the error is caused by adding a weights
argument to your aes()
definition, for example:
ggplot(d) + aes(y = Freq, x = Survived, weights=rnorm(nrow(d))) + geom_boxplot()
That's what ggsurvey
does, it adds weights
computed by survey
, so that's why you get the error in this case.
I noticed a missing dependency for creating the boxplox from the ggsurvey function. I get an error and a blank plot when running the following code:
library(ggplot2)
library(questionr)
library(survey)
d <- as.data.frame(Titanic)
dw <- survey::svydesign(ids = ~1, weights = ~Freq, data = d)
questionr::ggsurvey(dw) + aes(y = Freq, x = Survived) + geom_boxplot()
output:
The boxplot only rendered after I installed and loaded the quantreg package. However, I cannot locate where this is listed as a dependency and it does not automatically attach.
My session info is:
The conditions under which the boxplot will render after attaching the quantreg package are:
Hope this was helpful to flag! Thank you for the great package.