簡體   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