How to change points individually in plot with for loop having if() inside? R -


I have to make a digit color in conspiracy red if the value of "y" is below zero, otherwise green but thus all Dots get the same color I have tried the following:

  x   

but they are all green:

Image details here Enter

You pass to the color vector (one for every point) For ifelse :

  set.seed (1492) # random number generation reproducible X & lt; -c (rnorm (100,) y & lt; -c (rnorm (100)) x & lt; - sort (x, decreasing = FALSE) y & lt; - Sort (y, decrement = FALSE) plot (x, Y, col = ifelse (y & lt; 0, "red", "green"))   

 Enter image details here

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -