I am trying to create a line graph. I am able to create the plot but when trying to add points() / lines() nothing shows up.
plot(subset(dc, code == "RS")$date, subset(dc, code == "RS")$rp, type = "l", xlab = "Time", ylab = "Real price of cement", xlim=c(2005,2020), ylim=c(0,400))
title("States: RS, MG, MT, PE", line = 0.3)
points(subset(dc, code == "MG")$date, subset(dc, code == "MG")$rp, type = "l", col="red")
points(subset(dc, code == "MT")$date, subset(dc, code == "MT")$rp, type = "l",col="yellow")
points(subset(dc, code == "PE")$date, subset(dc, code == "PE")$rp, type = "l",col="blue")
This is especially confusing since I have copied the code from my profs solutions to the problem where the lines do show up. The only thing I altered to the solution was adding xlim =because of an error message.
I am also receiving warning in xy.coords(x, y) : NAs introduced by coercion. Could this be a problem?
I am wondering whether I need to download another package? Maybe the subset is an issue?
structure(list(X = 193:194, state = c("RIO GRANDE DO SUL", "RIO GRANDE DO SUL" ), year = c(2004L, 2004L), code = c("RS", "RS"), yearmonthday_str = c(20040101L, 20040201L), date = c("2004-01-01", "2004-02-01"), rp = c(155.802764892578, 154.858352661133)), row.names = 193:194, class = "data.frame")

Any help is appreciated.