Hi

or slightly quicker

y<-(x != "N")*1

HTH
Petr

On 16 Jun 2006 at 22:57, Dimitrios Rizopoulos wrote:

Date sent:              Fri, 16 Jun 2006 22:57:48 +0200
From:                   Dimitrios Rizopoulos <[EMAIL PROTECTED]>
To:                     "Davis, Jacob B. " <[EMAIL PROTECTED]>
Copies to:              [email protected]
Subject:                Re: [R] Vector Manipulation

> 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. " <[EMAIL PROTECTED]>:
> 
> > 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]]
> > 
> > ______________________________________________
> > [email protected] 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
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
[EMAIL PROTECTED]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to