Search code examples
rggplot2cran

Using qplot to make a dotplot


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()

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.