How about something like this?
fish <- as.factor(rep(c("Yes", "No"), 20))
depth <- as.factor(rep(c("Deep", "Shallow"), c(10,10)))
newfact <- as.factor(paste(as.character(fish), as.character(depth), sep=""))
Hope it helps.
Carlos Davidson wrote:
I would like to create a four level factor variable from two binary
factor variables. So for a dataset with 1000 plus sites I have
information on two different categorical binary variables (fish present
- yes/no, and lake depth deep/shallow) and I would like to create a
single factor variable with the factors "fishshallow","fishdeep",
"nofishdeep","nofishshallow". Any suggestions of code to do this - call
my two binary variales fish ( values "Y" and "N") and depth (values
"Deep","Shallow")?
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
|