plot.new has not been called yet

后端 未结 6 1691
北荒
北荒 2020-12-01 12:13

Why does this happen?

plot(x,y)
yx.lm <- lm(y ~ x)
lines(x, predict(yx.lm), col=\"red\")

Error in plot.xy(xy.coords

6条回答
  •  难免孤独
    2020-12-01 12:37

    In my case, I was trying to call plot(x, y) and lines(x, predict(yx.lm), col="red") in two separate chunks in Rmarkdown file. It worked without problems when running chunk by chunk, but the corresponding document wouldn't knit. After I moved all plotting calls within one chunk, problem was resolved.

提交回复
热议问题