如何用'p <0.001'替换非常重要的p值?

问题描述 投票:0回答:1

我用回归线和系数绘制了一个散点图,并获得了非常显着的p。是否可以将R(1.6e-5)自动提供的p值替换为'p <0.001'。

这是我的代码:

CorFrame2 <- data.frame(FFR2,iFR2)
ggplot(CorFrame2,aes(x=iFR2,y=FFR2))+
... +
stat_cor(aes(label = paste(..rr.label.., ..p.label.., sep = "~`,`~")),
       label.x = 0.20,label.y = 0.90,size=5)
r ggplot2 correlation p-value
1个回答
0
投票

ggpubr::stat_cor创建一个名为..p.label..的字符串-我们可以将其转换为数字,评估其是否小于0.001,并使用该值覆盖if_else语句中的值:

ggplot(mtcars,aes(x=wt,y=mpg))+
  geom_point() +
  ggpubr::stat_cor(
    aes(label = paste(..rr.label..,
                      if_else(readr::parse_number(..p.label..) < 0.001, 
                              "p<0.001", ..p.label..), sep = "~`,   `~")),
           label.x = 0.20,label.y = 0.90,size=5)

enter image description here

ggplot(mtcars,aes(x=wt,y=qsec))+相同,相关性较小:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.