Hi All:

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 "postgraduate").

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[1], x[2], (x[3]+x[4]+x[5]), x[6]))


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 wasn't successful.


-Arin Basu

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to