- ##plot()做比较箱图
- attach(ToothGrowth)
- plot(supp,len)
- 注解:只要第一个变量是因子,第二个是数值,自动生成比较箱图
- ##boxplot()做比较箱图
- boxplot(len~supp,data=ToothGrowth)
- ##boxplot()做比较箱图(交互比较)
- boxplot(len~supp+dose,data=ToothGrowth)
- ###ggplot2包做比较箱图
- ##qplot()做比较箱图
- library(ggplot2)
- qplot(supp,len,data=ToothGrowth,geom="boxplot")
- #它等价于
- ggplot(ToothGrowth,aes(x=supp,y=len))+geom_boxplot()
- ##qplot()做交互比较箱图
- library(qqplot2)
- qplot(interaction(supp,dose),len,data=ToothGrowth,geom="boxplot")
- #它等价于
- ggplot(ToothGrowth,aes(x=interaction(supp,dose),y=len))+geom_boxplot()