Hi, I am trying to use ifelse
inside the image
function as follows:
x <- y <- 1:5
z <- c(1:5, 2:6, 3:7, 4:8, 5:9)
z <- matrix(z, 5, 5)
image(x, y, z)
image(x, y, z, col = ifelse(z > 5, 'red', 'green'))
I would like to post both images but I'm a newbie so I can only post one. If you run the code, you should be able to see both images. The second one should look like this:
However, I expect it to have red in the upper-right triangle and green along the diagonal and in the lower-left triangle. Do you know why my code isn't generating that? Thank you for your help.