2016-02-28 64 views
1

使用R中的MPG数据,我可以让“显示终端”的箱线与错误制作一个简单的箱线时GGPLOT2

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' 

回答

3

ggplot2既需要的箱线图的xy变量。以下是如何制作单个箱型图

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