Question

I would like to make a wrapper for qplot that changes the default geom from histogram to dotplot if x is numeric and y is null. However I can't get qplot to work with geom_dotplot:

> x <- rnorm(100)
> qplot(x, geom="dotplot")
stat_bindot: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
Error in if (params$stackdir == "up") { : argument is of length zero

How can I use qplot to create this figure:

ggplot(,aes(x=x)) + geom_dotplot()
Was it helpful?

Solution

qplot is missing a default aesthetics set for geom_dotplot. You could specify them manually:

qplot(x, geom = "dotplot",
      stackdir = "up", stackgroups = FALSE, binaxis = "x")

Plus binwidth.

OTHER TIPS

Not really an answer, but consider these two attempts that do not throw errors:

g <- qplot(x)
g + geom_dotplot()  # makes a weird hybrid dotplot and barplot

Or:

g <- qplot(x, stat="bindot")
g    # was expecting dots but got bars, go figure.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top