Re: [R] Recoding a variable

2008-07-03 Thread Peter Dalgaard
John Fox wrote: Dear Spencer, In addition to the approaches already suggested, there is the recode() function in the car package. Or this way: levels(ftpain) <- list( none="none", intermediate=c("mild", "medium"), severe="severe") Or this (not quite as general): level

Re: [R] Recoding a variable

2008-07-03 Thread John Fox
Dear Spencer, In addition to the approaches already suggested, there is the recode() function in the car package. Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton ON Canada L8S 4M4 web: socserv.mcmaster.ca/jf

Re: [R] Recoding a variable

2008-07-03 Thread Stephan Kolassa
internet.use[internet.use=="Never" | internet.use=="Don't know"] <- 0 internet.use[internet.use!=0] <- 1 HTH, Stephan Spencer schrieb: Hi All, I'm relatively new to R. I have a variable, "internet use," which ranges from "Almost everyday, "Several times a week," "Several times a month," "S

Re: [R] Recoding a variable

2008-07-03 Thread jim holtman
Here is an example of a way to do it: > x <- sample(LETTERS[1:5], 20, TRUE) > x [1] "D" "E" "A" "B" "A" "E" "A" "E" "A" "E" "C" "D" "A" "E" "D" "E" "A" "C" "B" "B" > # new vector with "D" and "E" = 0 > new.x <- ifelse((x == "D") | (x == "E"), 0, 1) > cbind(x,new.x) x new.x [1,] "D" "0"

[R] Recoding a variable

2008-07-03 Thread Spencer
Hi All, I'm relatively new to R. I have a variable, "internet use," which ranges from "Almost everyday, "Several times a week," "Several times a month," "Seldom," "Never," and "Don't know." I want to recode this data into a new variable, say "use.internet," such that I have a dichotomous var