to: r-help@stat.math.ethz.ch
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
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]]
I think you want
ifelse(x=='N',0,1)
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Davis,
Jacob B.
Sent: Friday, June 16, 2006 4:46 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Vector Manipulation
I have a vector that has 1,974 elements
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: