Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将p值或星号添加到ggplot_R_Ggplot2_Ggpubr - Fatal编程技术网

R 将p值或星号添加到ggplot

R 将p值或星号添加到ggplot,r,ggplot2,ggpubr,R,Ggplot2,Ggpubr,我想要的是成对比较,例如配对威尔科克斯检验。分组:列表(c(“0.5”、“1”)、c(“1”、“2”)、c(“2”、“3”))。非常简单,一开始没有alpha校正等等 代码: 一种简单的方法是手动添加符号: p + annotate("text", x = 0.5, y = 23, label = "ns") + annotate("text", x = 1.5, y = 30, label = "**") + annotate("text", x = 2.5, y = 48, la

我想要的是成对比较,例如配对威尔科克斯检验。分组:
列表(c(“0.5”、“1”)、c(“1”、“2”)、c(“2”、“3”))
。非常简单,一开始没有alpha校正等等

代码:
一种简单的方法是手动添加符号:

  p + annotate("text", x = 0.5, y = 23, label = "ns") +
  annotate("text", x = 1.5, y = 30, label = "**") +
  annotate("text", x = 2.5, y = 48, label = "***") 
根据github回购问题,这是软件包的问题。作者建议手动计算p值,并按如下方式使用:

geom_signif(annotations = c(formatC(annot_1, digits=3),formatC(annot_2, digits=3)), y_position = c(150, 180), xmin=c(1.2, 0.8), xmax=c(2.2, 1.8))

其中
annot_1
annot_2
是预先计算的p值

运行此代码会出现错误,因为找不到
df_orig
。抱歉,我已修复此问题,我将标记此问题。我想我可以用这个来构造一个通用的解决方案。
  p + annotate("text", x = 0.5, y = 23, label = "ns") +
  annotate("text", x = 1.5, y = 30, label = "**") +
  annotate("text", x = 2.5, y = 48, label = "***") 
geom_signif(annotations = c(formatC(annot_1, digits=3),formatC(annot_2, digits=3)), y_position = c(150, 180), xmin=c(1.2, 0.8), xmax=c(2.2, 1.8))