Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.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
ggpubr:在标签中显示显著性水平(***或n.s.),而不是p值_R_Ggplot2_Ggpubr - Fatal编程技术网

ggpubr:在标签中显示显著性水平(***或n.s.),而不是p值

ggpubr:在标签中显示显著性水平(***或n.s.),而不是p值,r,ggplot2,ggpubr,R,Ggplot2,Ggpubr,我想用R中的ggpubr将显著性水平(***或n.s.)显示为线性回归中的标签。这似乎是通过使用aes(标签=…p.signif..)完成的,如下所示: 但是,当我在我的stat\u cor(aes(label=paste(..rr.label….,..p.label….,sep=“,~”)中将.p.label..替换为.p.signif../code>)中的.p.label..时,ie.stat cor aes(label=paste(..rr label.label…..signif….,s

我想用R中的
ggpubr
将显著性水平(
***
n.s.
)显示为线性回归中的标签。这似乎是通过使用
aes(标签=…p.signif..)
完成的,如下所示:

但是,当我在我的
stat\u cor(aes(label=paste(..rr.label….,..p.label….,sep=“
~”)中将
.p.label..
替换为
.p.signif../code>)中的
.p.label..
时,
ie.stat cor aes(label=paste(..rr label.label…..signif….,sep.sep=“
~”)我的绘图没有任何更改,只是得到一个错误:

Error in paste(rr.label, p.signif, sep = "~`,`~") : 
  object 'p.signif' not found 
请问,我如何绘制星号(*,,*)或n.s.值,而不是绘图上的精确p值?非常感谢

我的虚拟数据:(借用自)


库(ggpubr)
数据(“mtcars”)

df您可以使用
cut

ggscatter(df, x = "wt", y = "mpg",
          add = "reg.line",                         # Add regression line
          conf.int = TRUE,                          # Add confidence interval
          color = "cyl", palette = "jco",           # Color by groups "cyl"
          shape = "cyl"                             # Change point shape by groups "cyl"
)+
  stat_cor(aes(color = cyl,
               label =paste(..rr.label.., cut(..p.., 
                                              breaks = c(-Inf, 0.0001, 0.001, 0.01, 0.05, Inf),
                                              labels = c("'****'", "'***'", "'**'", "'*'", "'ns'")), 
                            sep = "~")), 
           label.x = 3)   


不用说,显示p值(或者更好的是,置信区间)要好得多。

非常感谢@Roland。但是,当我运行您的解决方案时,我返回并出错:
错误在
级别
ggscatter(df, x = "wt", y = "mpg",
          add = "reg.line",                         # Add regression line
          conf.int = TRUE,                          # Add confidence interval
          color = "cyl", palette = "jco",           # Color by groups "cyl"
          shape = "cyl"                             # Change point shape by groups "cyl"
)+
  stat_cor(aes(color = cyl,
               label =paste(..rr.label.., cut(..p.., 
                                              breaks = c(-Inf, 0.0001, 0.001, 0.01, 0.05, Inf),
                                              labels = c("'****'", "'***'", "'**'", "'*'", "'ns'")), 
                            sep = "~")), 
           label.x = 3)