[R] Vector Manipulation

Dimitrios Rizopoulos Dimitris.Rizopoulos at med.kuleuven.be
Fri Jun 16 22:57:48 CEST 2006


try the following:

x <- c("B", "F", "N", "Y")
################
y <- numeric(length(x))
y[x != "N"] <- 1
y


I hope it helps.

Best,
Dimitris

---- 
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting "Davis, Jacob B. " <JBDavis at txfb-ins.com>:

> I have a vector that has 1,974 elements and each element is one of
> the
> following (B, F, N, Y).  How do I recreate that vector accept in the
> place of N put 0 and in the place of B, F or Y put a 1?
> 
>  
> 
> Thanks,
> 
> Jacob
> 
>  
> 
>  
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> 
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list