繁体   English   中英

如何使用R中的plot函数绘制带有点的多条线?

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

我是R的新手,并尝试使用简单的plot()函数绘制图形。 因此,我编写了以下代码:

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)

我收到此消息:

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

有什么帮助和建议吗?

您只需要删除代码中多余的括号即可。

更改此(g/bee)") ) lines

到此代码(g/bee)") lines

完整的代码

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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