简体   繁体   中英

How to plot several lines with points using the plot function in R?

I am new to R and trying to plot a graph using the simple plot() function. So, I wrote this code:

d=read.csv("Nutrition assay example") 
head(d) 
plot(d$Carbs0~d$EAAs0, typ="p", pch=19, ylab="Carbohydrate (g/bee)", xlab="Amino acids (g/bee)") ) lines(d$Carbs0~d$EAAs0) 
lines(d$Carbs1~d$EAAs1, col="red") 
points(d$Carbs1~d$EAAs1, col="red", pch=19)

I get this message:

Error in (function (formula, data = NULL, subset = NULL, na.action = na.fail,  :    invalid type (NULL) for variable 'd$Carbs1'

Any help and suggestions?

You just need to remove the extra parenthesis in your code.

Change this (g/bee)") ) lines

To this code (g/bee)") lines

Complete Code

d=read.csv("Nutrition assay example") 
head(d) 
plot(d$Carbs0~d$EAAs0, typ="p", pch=19, ylab="Carbohydrate (g/bee)", xlab="Amino acids (g/bee)")
lines(d$Carbs0~d$EAAs0)
lines(d$Carbs1~d$EAAs1, col="red")
points(d$Carbs1~d$EAAs1, col="red", pch=19)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM