Reputation: 359
Using the mpg data in R, I can make a boxplot of 'displ' with
boxplot(mpg$displ)
But when I try to make this simple boxplot with ggplot,
ggplot(data = mpg, aes(displ)) + geom_boxplot()
I get this error;
Error in seq.default(from = best$lmin, to = best$lmax, by = best$lstep) : 'from' must be of length 1
In addition: Warning messages:
1: Continuous x aesthetic -- did you forget aes(group=...)?
2: In is.na(data$y) : is.na() applied to non-(list or vector) of type 'NULL'
Upvotes: 3
Views: 6305
Reputation: 18487
ggplot2
requires both an x
and y
variable of a boxplot. Here is how to make a single boxplot
ggplot(data = mpg, aes(x = "", y = displ)) +
geom_boxplot() +
theme(axis.title.x = element_blank())
Upvotes: 7