lundi 2 février 2015

Using ifelse to choose pch depending on a value in a vector in R

I am trying to use plot() to make a graph. I have two groups in my dataset, those with y=1 and those with y=-1. I would like to make it so that those y=1 use pch symbol 1, and those with y=-1 use symbol 4.


I have tried several variations of plot(x1, x2, pch=ifelse(y=1, 1, 4)) but in the end they all end up using shape 1. Is there a way I could use a loop or something to access the values at each index in y? I have checked that the values in y are not all 1 so that should not be an issue.


Thanks!


Aucun commentaire:

Enregistrer un commentaire