jeudi 4 février 2016

R: condition coloring points

I have a data of temperatures and dates. I plotted it and now I would like to color only certain ones, but only if three points suffice the condition. Example: my limit is 30 and if 3 points in the graph are over 30, they color red.

I tried with formula:

plot(x= c(1:365), y=c(1:365), type = "l",xlim = c(1, 365),
ylim = c(-10, 50), xlab = "", ylab = "", col = 1, lwd = 2, axes = FALSE)
par(new=T)
plot(x=c(1:365), y=c(-10,50), col=ifelse(y>30, "red", "black"))

I tried to find an answer to my question, but somehow I didn't find anything. It is possible that I just didn't try the right keywords. If anybody knows that this is somewhere already answered/explained, you can just redirect me there.

Thank you for help :)

Aucun commentaire:

Enregistrer un commentaire