[R] problems with categorical variables
arinbasu at softhome.net
Mon Sep 8 14:36:40 CEST 2003
I am working on a dataset of a study on healthcare workers. One of the
variables I am studying is a categorical variable (variable name:EDUC,
indicates educational achievement, with 6 levels: "illiterate", "primary",
"junior high school", "high school completed", "undergraduate", and
I want to collapse the 6 levels to a 4-level categorical variable (let's
call it "educrec", with the following levels: "postgraduate",
"undergraduate", "some schooling" and "illiterate").
I initially tried the following code:
x <- table(EDUC)
educrec <- c(x, x, (x+x+x), x))
table(educrec) gives me the tally count just fine, but I cannot use educrec
in any cross tabulation.
Would greatly appreciate if you can advise on the correct way to recode
categorical variables to categorical variables in R.
I use Windows XP (Home), R-version 1.7.1
I looked for solutions in the "introduction to R" and the archives, but
More information about the R-help