标签: r plot linear-regression
假设你有一个方程组(5个方程和2个变量),如下所示:
Ax + By = C AB <- matrix(runif(10), 5) C <- c(5, 10, 15, 20, 25)
如何在R中绘制这个方程组,而不先手动转换为
y = (C - Ax) / B
答案 0 :(得分:1)
你在找这样的东西吗?
set.seed(101) AB <- matrix(runif(10), 5) C <- c(5, 10, 15, 20, 25) x = seq(-70,70,1) plot(x, (C[1] - AB[1,1]*x)/AB[1,2], col=1, type="l", ylim=c(-100,200)) for (i in 2:nrow(AB)) { lines(x, (C[i] - AB[i,1]*x)/AB[i,2], col=i, type="l") }