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
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
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
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"
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
5 matches
Mail list logo