在圖上增加回歸線方程和R2我想知道如何將回歸線方程和R^2添加到ggplot..我的代碼是library(ggplot2)df <- data.frame(x = c(1:100))df$y <- 2 + 3 * df$x + rnorm(100, sd = 40)p <- ggplot(data = df, aes(x = x, y = y)) +
geom_smooth(method = "lm", se=FALSE, color="black", formula = y ~ x) +
geom_point()p任何幫助都將不勝感激。
- 3 回答
- 0 關(guān)注
- 1098 瀏覽
添加回答
舉報(bào)
0/150
提交
取消