如何使用指数(科学)表示法打印 p 值?
当使用“ggplot”在 R 中打印值时,我面临着正确编写指数的问题。请参阅下面的图,以及我想要获得的红色手写内容的示例。
data <- data.frame(var = 1:10,
pvalue=c(0.1,0.001,0.0000133233,0.2,0.2222,0.43254,0.1,0.67,0.6777,0.2)) %>%
mutate(pvalue=as.character(signif(pvalue,digits=2)))# %>%mutate(pvalue = sub("e","10^",pvalue) )
data %>%
ggplot(aes(y = var)) +
geom_text(aes(x = 0, label = pvalue), parse=T)
When printing values in R using 'ggplot', I'm facing issues to write the exponent proprerly. See the plot below, and an example of what I would like to obtain hand-written in red.
data <- data.frame(var = 1:10,
pvalue=c(0.1,0.001,0.0000133233,0.2,0.2222,0.43254,0.1,0.67,0.6777,0.2)) %>%
mutate(pvalue=as.character(signif(pvalue,digits=2)))# %>%mutate(pvalue = sub("e","10^",pvalue) )
data %>%
ggplot(aes(y = var)) +
geom_text(aes(x = 0, label = pvalue), parse=T)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只需将
e
的值更改为指数形式,则只需在注释代码中添加%.%
即可。结果:
If you only need to change the values with
e
to exponent forms, you only need to add%.%
to your commented code.The result: