简体   繁体   中英

R boxplot vs ggplot2 geom_boxplot

Why are the boxplots so different?

boxplot(loan.part.value ~ platform, p2p)

在此处输入图片说明

ggplot(p2p, aes(loan.part.value, platform)) + geom_boxplot()

在此处输入图片说明

(I redacted the tick labels.)

> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_0.9.3.1

Because the order is switched in one of your plots. In boxplot the formula is y ~ x where as ggplot2 has the first positional argument of x .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM