Forums | OpenR

OpenR: R & Statistics /
Question about how to solve the error of lines() in R Markdown


Jie Ji's profile picture
Posts: 7

23 March 2022, 11:47 PM

I have an error of lines() in R Markdown. The code in R Script has no error. So I'm writing for help.

RMD.png

Jie Ji's profile picture
Posts: 7

24 March 2022, 12:23 AM

I solve it by using this code, but I don't know whether it is the optimal solution.

Solution.png

 

 

Peng Zhao's profile picture
Posts: 128

24 March 2022, 4:37 PM

The lines() function is so-called a low-level function. It cannot work alone. It must be based on an existing graph, created by a high-level function such as plot(). We usually do it like this:

plot(age, bone, pch = 16)
lines(av, bv)

Other low-level functions include axis(), points(), legend() ... Other high-level functions include pairs(), boxplot(), hist() ...

BTW, please post your code rather than the screenshot, so that other people do not have to type your code and test it.

3 results