|
发表于 2022-9-20 08:45:33
|
查看: 1309 |
回复: 0
一、箱线图
- ToothGrowth
- boxplot(len ~ dose, data = ToothGrowth)
- boxplot(len ~ supp, data = ToothGrowth)
- boxplot(len ~ dose:supp, data = ToothGrowth)
- # boxplot(len ~ dose+supp, data = ToothGrowth)
- boxplot(len ~ supp+dose, data = ToothGrowth)
- library(RColorBrewer)
- brewer.pal(n = 3,name = 'Set2')
- boxplot(len ~ supp+dose, data = ToothGrowth,
- col = c("#66C2A5","#FC8D62"))
- boxplot(len ~ supp+dose, data = ToothGrowth,
- col = c("#66C2A5","#FC8D62"),notch=T)#画出凹口,可比较上下数据多少
- boxplot(len ~ supp+dose, data = ToothGrowth,
- col = c("#66C2A5","#FC8D62"),horizontal = T)
- t.test(ToothGrowth$len[ToothGrowth$supp == 'OJ'& ToothGrowth$dose == 0.5],
- ToothGrowth$len[ToothGrowth$supp == 'VC'& ToothGrowth$dose == 0.5])
复制代码
带凹口的箱线图
二、小提琴图
- library(vioplot)
- vioplot(len ~ supp+dose, data = ToothGrowth,
- col = c("#66C2A5","#FC8D62"))
- vioplot(len ~ supp+dose, data = ToothGrowth,
- col = c("#66C2A5","#FC8D62"),
- main = 'OJ vs VC',
- xlab = 'Supp and Dose',
- ylab = 'Tooth Length')
- example(vioplot)
- par(mfrow=c(1,1))#恢复案例后的绘图区域布局
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
|