生信人

找回密码
立即注册
搜索
热搜: 活动 交友 discuz
发新帖

0

收听

12

听众

318

主题
发表于 2022-9-20 08:45:33 | 查看: 1309| 回复: 0
一、箱线图
  1. ToothGrowth
  2. boxplot(len ~ dose, data = ToothGrowth)
  3. boxplot(len ~ supp, data = ToothGrowth)
  4. boxplot(len ~ dose:supp, data = ToothGrowth)
  5. # boxplot(len ~ dose+supp, data = ToothGrowth)
  6. boxplot(len ~ supp+dose, data = ToothGrowth)
  7. library(RColorBrewer)
  8. brewer.pal(n = 3,name = 'Set2')
  9. boxplot(len ~ supp+dose, data = ToothGrowth,
  10.         col = c("#66C2A5","#FC8D62"))
  11. boxplot(len ~ supp+dose, data = ToothGrowth,
  12.         col = c("#66C2A5","#FC8D62"),notch=T)#画出凹口,可比较上下数据多少
  13. boxplot(len ~ supp+dose, data = ToothGrowth,
  14.         col = c("#66C2A5","#FC8D62"),horizontal = T)
  15. t.test(ToothGrowth$len[ToothGrowth$supp == 'OJ'& ToothGrowth$dose == 0.5],
  16.        ToothGrowth$len[ToothGrowth$supp == 'VC'& ToothGrowth$dose == 0.5])
复制代码
      
       带凹口的箱线图

二、小提琴图
  1. library(vioplot)
  2. vioplot(len ~ supp+dose, data = ToothGrowth,
  3.         col = c("#66C2A5","#FC8D62"))
  4. vioplot(len ~ supp+dose, data = ToothGrowth,
  5.         col = c("#66C2A5","#FC8D62"),
  6.         main = 'OJ vs VC',
  7.         xlab = 'Supp and Dose',
  8.         ylab = 'Tooth Length')
  9. example(vioplot)
  10. par(mfrow=c(1,1))#恢复案例后的绘图区域布局
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

您需要登录后才可以回帖 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|生信人 ( 萌ICP备20244422号 )

GMT+8, 2024-11-23 21:36 , Processed in 0.101793 second(s), 30 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表