2016-02-28 38 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())