[R] Getting tripped up on NAs in trying to create new variable

2010-10-17 Thread Greg Blevins
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

[R] library error on start up, error on update packages

2009-01-08 Thread Greg Blevins
es\R\R-2.8.1\Library--I have not found the location where the newly installed package actually resides, but R is smart enough to locate it when I load the package. I am wondering if I have some VISTA setting or administrative rights issue? Any help would be appreciated. Greg Blevins ==

[R] recode involving a count rule

2008-05-03 Thread Greg Blevins
Hello, R-helpers. I have a data frame below called df. I want to add a variable c, based on the following logic: if df$a < 5 then the first two times this condition is met place a 1 in c, the next two times this condition is met place a 2 in c and when the condition is not met let c equal df$b.