我正在尝试创建一个图,该图的观察/点颜色取决于另一个变量。该变量称为treat,仅由两个字符串“ chilled”和“ unchilled”组成。
我编写了以下代码来获取图形:
chill_frame_four <- filter(chill_data, chill_data$spec %in% "Lolium perenne")
chill_plot_four %<a-% (plot(chill_frame_four$conc, chill_frame_four$photo, col=c("blue", "darkgreen")[as.numeric(chill_frame_four$treat)], pch=16,
xlab="CO2 Concentration (PPM)", ylab="Photosynthetic Rate (µmol m-2 s -1)", main = expression(italic("Lolium Perenne"))) +
legend(x = "bottomright", legend = c("Chilled", "Unchilled"), pch = 16, col=c("blue", "darkgreen"), bty = "n", xpd=TRUE, title="Treatment Type", cex= 0.75))
调用chill_plot_four对象时,图形将输出并按预期显示,如下面的屏幕快照所示。
但是我在控制台上遇到错误,如下所示:
Error in plot(chill_frame_four$conc, chill_frame_four$photo, col = c("blue", :
non-numeric argument to binary operator
该图形似乎正在运行,但是控制台中出现错误。不知道我在做什么错。
chill_frame_four数据:https://gist.github.com/SakshamInABox/25ca2d6bf37076a9ec7eb62f9effef88