自学做视频网站,网站建设企业排行榜,哈尔滨制作网站,启动网站集约化建设目录
数据
计算四分位值
作图
数据
rm(list ls())
library(ggplot2)
library(dplyr)
library(ggpubr)
library(reshape2)
library(tidyverse)data - iris##鸢尾花数据集
dat - data[,c(5,1)]#单个数据进行分析
计算四分位值
#根据分组计算四分位及中位数
dat1 …目录
数据
计算四分位值
作图
数据
rm(list ls())
library(ggplot2)
library(dplyr)
library(ggpubr)
library(reshape2)
library(tidyverse)data - iris##鸢尾花数据集
dat - data[,c(5,1)]#单个数据进行分析
计算四分位值
#根据分组计算四分位及中位数
dat1 - dat %% Species_by(Species) %% mutate(upper quantile(Sepal.Length, 0.75), lower quantile(Sepal.Length, 0.25),mean mean(Sepal.Length),median median(Sepal.Length))head(dat1)
# A tibble: 6 × 6
# Groups: Species [1]Species Sepal.Length upper lower mean medianfct dbl dbl dbl dbl dbl
1 setosa 5.1 5.2 4.8 5.01 5
2 setosa 4.9 5.2 4.8 5.01 5
3 setosa 4.7 5.2 4.8 5.01 5
作图
#比较分组
my_comparisons list( c(setosa,versicolor),c(versicolor,virginica),c(setosa,virginica))
P - ggplot(dat1,aes(xSpecies,ySepal.Length)) #ggplot作图geom_jitter(shape 21,aes(fillSpecies),width 0.25) stat_summary(funmean, geompoint, colorgrey60) theme_cowplot() theme(axis.text element_text(size 10),axis.title element_text(size 10),legend.text element_text(size 10),legend.title element_text(size 10),plot.title element_text(size 10,face plain),legend.position none) labs(title Species,ySepal.Lengthage) geom_errorbar(aes(ymin lower, ymax upper),col grey60,width 1)#误差棒#差异检验stat_compare_means(comparisonsmy_comparisons,label.y c(7.5, 8, 8.5),methodt.test,#wilcox.testlabelp.signif)
P
dev.off() ggplot2画各种误差线和森林图 - 知乎 (zhihu.com)
R进阶绘图--散点箱线图显著性 / 组间差异比较 / ggpubr包 - 知乎 (zhihu.com)