R 使用ggplot2制作简单箱线图时出错

R 使用ggplot2制作简单箱线图时出错,r,ggplot2,R,Ggplot2,使用R中的mpg数据,我可以用 boxplot(mpg$displ) 但是当我试着用ggplot做这个简单的箱线图时 ggplot(data = mpg, aes(displ)) + geom_boxplot() 我得到这个错误 Error in seq.default(from = best$lmin, to = best$lmax, by = best$lstep) : 'from' must be of length 1 In addition: Warning messages: 1

使用R中的mpg数据,我可以用

boxplot(mpg$displ)
但是当我试着用ggplot做这个简单的箱线图时

ggplot(data = mpg, aes(displ)) + geom_boxplot()
我得到这个错误

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
需要箱线图的
x
y
变量。下面是如何制作单个箱线图

ggplot(data = mpg, aes(x = "", y = displ)) + 
  geom_boxplot() + 
  theme(axis.title.x = element_blank())