繁体   English   中英

在ggplot2 R mtcars示例中接收stat_smooth的等式

[英]Receive the equation of the stat_smooth in ggplot2 R mtcars example

嗨,我想知道如何在ggplot2或矢量或其他地方检索stat_smooth的等式。 我正在使用的代码是:

p <- ggplot(data = mtcars, aes(x = disp, y = drat)) 
p <- p + geom_point() + stat_smooth(method="loess") 
p

谢谢

ggpmisc软件包可能非常有用。 但是,它不适用于黄土,因为黄土没有给出公式。 参见此处: 黄土拟合和所得方程

library(ggplot2)
library(ggpmisc)
p <- ggplot(data = mtcars, aes(x = disp, y = drat)) +
  geom_point() + 
  geom_smooth(method="lm", formula=y~x) +
  stat_poly_eq(parse=T, aes(label = ..eq.label..), formula=y~x)
p

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM