gglmannotate 轻松添加线形回归统计指标
测试开头








测试结尾
贫贱不能移,威武不能屈

1引言
今天分享一个 R 包 gglmannotate
可以在 ggplot 图上 快速轻松添加线形回归模型相关的统计指标 。
2安装
# install
devtools::install_github("wilkox/gglmannotate")
3使用介绍
使用 geom_lmannotate()
函数添加统计指标:
library(ggplot2)
library(gglmannotate)
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
geom_smooth(method = "lm") +
geom_lmannotate()

分组颜色映射:
ggplot(mpg, aes(x = displ, y = hwy, colour = class)) +
geom_point() +
geom_smooth(method = "lm") +
geom_lmannotate()

分面:
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
geom_smooth(method = "lm") +
geom_lmannotate() +
facet_wrap(~ class)

4自定义统计指标
通过 glue_exp 参数自定义格式:
ggplot(mpg, aes(x = displ, y = hwy, colour = class)) +
geom_point() +
geom_smooth(method = "lm") +
geom_lmannotate(glue_exp = "Max residual: {signif(max(model$residuals), 2)}")

5自定义文本位置
通过 region 和 place 参数调整:
ggplot(mpg, aes(x = hwy, y = cty, colour = class)) +
geom_point() +
geom_smooth(method = "lm") +
geom_lmannotate(
region = c(xmin = 0, xmax = 0.75, ymin = 0.75, ymax = 1),
place = "topleft"
)


欢迎加入生信交流群。加我微信我也拉你进 微信群聊 老俊俊生信交流群
哦,数据代码已上传至QQ群,欢迎加入下载。
群二维码:

老俊俊微信:
知识星球:
所以今天你学习了吗?
欢迎小伙伴留言评论!
今天的分享就到这里了,敬请期待下一篇!
最后欢迎大家分享转发,您的点赞是对我的鼓励和肯定!
如果觉得对您帮助很大,赏杯快乐水喝喝吧!
往期回顾
◀基于 featureCounts 原理提取基因非冗余外显子长度
◀python 学习之 featureCounts 软件的基因长度是怎么算的?
◀python 学习之 python 里也能用 dplyr?
◀...
请关注“恒诺新知”微信公众号,感谢“R语言“,”数据那些事儿“,”老俊俊的生信笔记“,”冷🈚️思“,“珞珈R”,“生信星球”的支持!