On Sun, Oct 17, 2010 at 9:03 PM, Greg Blevins wrote:
> Hello R help:
>
> I have the following data:
>
> a <- c(NA, 2, 2, 3, 2, NA)
> b <- c(NA, NA, 3, NA, 1, 3)
> df <- data.frame(a, b)
>> df
> a b
> 1 NA NA
> 2 2 NA
> 3 2 3
> 4 3 NA
> 5 2 1
> 6 NA 3
>
> I want to create variable c such
om: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Greg Blevins
> Sent: Monday, 18 October 2010 2:04 p.m.
> To: r-help@r-project.org
> Subject: [R] Getting tripped up on NAs in trying to create new variable
>
> Hello R help:
>
> I have the
Hello R help:
I have the following data:
a <- c(NA, 2, 2, 3, 2, NA)
b <- c(NA, NA, 3, NA, 1, 3)
df <- data.frame(a, b)
> df
a b
1 NA NA
2 2 NA
3 2 3
4 3 NA
5 2 1
6 NA 3
I want to create variable c such that if there is a 3 in either variable a
or variable b, variable c is 1(rows 3, 4
3 matches
Mail list logo