[R] simple if statement
Philipp Pagel
philipp.pagel.lists at t-online.de
Fri Apr 7 10:06:50 CEST 2006
On Fri, Apr 07, 2006 at 09:55:47AM +0200, Philipp Pagel wrote:
> On Fri, Apr 07, 2006 at 02:58:00AM -0400, Brian Quinif wrote:
> > I tried this
> > years <- "Freshmen" if i==1
> > years <- "Sophomores" if i==2
>
> What you are looking for is not an if clause but logical indexing:
>
> years[years=="Freshmen"] <- 1
> years[years=="Sophomores"] <- 2
[...]
OK - I'll have to comment myself: I misread your message and it does not
make sense for you question.
Others have given good answers in the meantime...
cu
Philipp
--
Dr. Philipp Pagel Tel. +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany
and
Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675
GSF - National Research Center Fax. +49-89-3187 3585
for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel
More information about the R-help
mailing list