[R] replace a value in a vector

Paul Lepp pwlepp at pmgm2.stanford.edu
Thu Oct 7 23:13:48 CEST 2004


OK, so this is a really stupid question and should be incredibly simple to
do but I can't figure it out. So maybe someone would be so kind as to tell
me.
I have a vector of zeros and ones.  I want to replace all of the zeros with
"black" and all of the ones with "gray".  That's it.  Any help would be
appreciated.

Thanks,
Paul

 `-:-.   ,-;"`-:-.   ,-;"`-:-.   ,-;"`-:-.   ,-;"`-:-.   ,-;"`-:-.
   `=`,'=/     `=`,'=/     `=`,'=/     `=`,'=/     `=`,'=/     `=`
     >==/        >==/        >==/        >==/        >==/
   ,=,-<=`.    ,=,-<=`.    ,=,-<=`.    ,=,-<=`.    ,=,-<=`.    ,=,
,-'-'   `-=_,-'-'   `-=_,-'-'   `-=_,-'-'   `-=_,-'-'   `-=_,-'-'
Paul Lepp, Ph.D.                       Stanford School of Medicine

VAPAHCS, 154T                   Dept. of Microbiology & Immunology
3801 Miranda Ave                               Stanford University
Palo Alto, CA 94304                                   Stanford, CA
(650) 493-5000 x66762		               fax: (650) 852-3291
http://cmgm.stanford.edu/~pwlepp          pwlepp at cmgm.stanford.edu




More information about the R-help mailing list