添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
# p値を追加する
# 比較した群、順番をまず指定する
my_comparisons <- list( c("setosa", "versicolor"), c("versicolor", "virginica"), c("setosa", "virginica") )
# 各群比較, p 数値表記(上段右図)
ggboxplot(iris, x = "Species", y = "Sepal.Length", color = "Species")  +
  stat_compare_means(comparisons = my_comparisons) + # Add pairwise comparisons p-value
  stat_compare_means(label.y = 10) +                            # Add global p-value
  ggtitle("各群比較, p 数値表記")
# 各群比較, p *表(上段左図)
ggboxplot(iris, x = "Species", y = "Sepal.Length", color = "Species")  +
  stat_compare_means(comparisons = my_comparisons, label = "p.signif") + # Add pairwise comparisons p-value
  stat_compare_means(label.y = 10) +
  ggtitle("各群比較, p *表記")
# 特定群だけに対する検定(下段左図)
ggboxplot(iris, x = "Species", y = "Sepal.Length", color = "Species")  +
 stat_compare_means(label.y = 10) +
 stat_compare_means(label = "p.signif", method = "t.test",  ref.group = "setosa") +
 ggtitle("setosa群のみ対する検定")
# 全体平均に対する検定(下段右図)
ggboxplot(iris, x = "Species", y = "Sepal.Length", color = "Species") +
stat_compare_means(label = "p.signif", method = "t.test",  ref.group = ".all.") + 
geom_hline(yintercept = mean(iris$"Sepal.Length"), linetype = 2)+ # Add horizontal line at base mean  
ggtitle("全体平均に対する検定")
# General correlation plot
ggscatter(iris, x = "Sepal.Length", y = "Sepal.Width",
          add = "reg.line",   # Add regression line
          conf.int = TRUE,    # Add confidence interval
          ) +  stat_cor(method = "spearman",  cor.coef.name = "rho") 
# plot with groups
ggscatter(iris, x = "Sepal.Length", y = "Sepal.Width",
          add = "reg.line",   # Add regression line
          conf.int = TRUE,    # Add confidence interval
          color = "Species", size=1
          ) +  stat_cor(aes(color = Species), method = "spearman",  cor.coef.name = "rho")