Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图在一个简单的 R 图中获取图例以报告系数(即斜率),而无需手动提取值。有谁知道如何对图例进行编码,以便它显示值而不是命令?谢谢
y <- rnorm(100) x <- sample(rnorm(100), 100, replace = TRUE) plot(x, y) mod <- lm(y ~x) abline(lm(y~x)) legend("topleft", "Slope = coef(mod)[2]", col = "black", pch = 15, cex = .8)
paste0("Slope = ", coef(mod)[2])