![](/img/trans.png)
[英]Different slope in 'regression' between ggplot (by suing geom_smooth(method = “lm”) , and lm -function
[英]How to take the slope of the lm regression in the ggplot
我使用ggplot在x和y變量之間有一個plot,特別是以下代碼:
ggplot(data = dataset, aes(x = X, y = log_Y, colour = Year)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE)
有什么方法可以采用 lm 回歸創建的線的斜率?
提前致謝!
使用broom
package,簡化了提取model數據的過程。 例如:
library(broom)
library(dplyr)
fit <- lm(mpg ~ cyl, data = mtcars)
summary(fit)
fit %>%
tidy() %>%
filter(term == "cyl") %>%
pull(estimate)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.