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'
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())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.