## Not run:
#
# ### for a description see http://popcenter.uchicago.edu/data/chfls.shtml
# library("TH.data")
# load(file.path(path.package(package="TH.data"), "rda", "CHFLS.rda"))
#
# tmp <- chfls1[, c("REGION6", "ZJ05", "ZJ06", "A35", "ZJ07", "ZJ16M", "INCRM",
# "JK01", "JK02", "JK20", "HY04", "HY07", "A02", "AGEGAPM",
# "A07M", "A14", "A21", "A22M", "A23", "AX16", "INCAM", "SEXNOW", "ZW04")]
#
# names(tmp) <- c("Region",
# "Rgender", ### gender of respondent
# "Rage", ### age of respondent
# "RagestartA", ### age of respondent at beginning of relationship
# ### with partner A
# "Redu", ### education of respondent
# "RincomeM", ### rounded monthly income of respondent
# "RincomeComp", ### inputed monthly income of respondent
# "Rhealth", ### health condition respondent
# "Rheight", ### respondent's height
# "Rhappy", ### respondent's happiness
# "Rmartial", ### respondent's marital status
# "RhasA", ### R has current A partner
# "Agender", ### gender of partner A
# "RAagegap", ### age gap
# "RAstartage", ### age at marriage
# "Aheight", ### height of partner A
# "Aedu", ### education of partner A
# "AincomeM", ### rounded partner A income
# "AincomeEst", ### estimated partner A income
# "orgasm", ### orgasm frequency
# "AincomeComp", ### imputed partner A income
# "Rsexnow", ### has sex last year
# "Rhomosexual") ### R is homosexual
#
# ### code missing values
# tmp$AincomeM[tmp$AincomeM < 0] <- NA
# tmp$RincomeM[tmp$RincomeM < 0] <- NA
# tmp$Aheight[tmp$Aheight < 0] <- NA
#
# olevels <- c("never", "rarely", "sometimes", "often", "always")
# tmpA <- subset(tmp, Rgender == "female" & Rhomosexual != "yes" & orgasm %in% olevels)
#
# ### 1534 subjects
# dim(tmpA)
#
# CHFLS <- tmpA[, c("Region", "Rage", "Redu", "RincomeComp", "Rhealth", "Rheight", "Rhappy",
# "Aheight", "Aedu", "AincomeComp")]
# names(CHFLS) <- c("R_region", "R_age", "R_edu", "R_income", "R_health", "R_height",
# "R_happy", "A_height", "A_edu", "A_income")
# levels(CHFLS$R_region) <- c("Coastal South", "Coastal Easth", "Inlands", "North",
# "Northeast", "Central West")
#
# CHFLS$R_edu <- ordered(as.character(CHFLS$R_edu), levels = c("no school", "primary",
# "low mid", "up mid", "j col", "univ/grad"))
# levels(CHFLS$R_edu) <- c("Never attended school", "Elementary school", "Junior high school",
# "Senior high school", "Junior college", "University")
# CHFLS$A_edu <- ordered(as.character(CHFLS$A_edu), levels = c("no school", "primary",
# "low mid", "up mid", "j col", "univ/grad"))
# levels(CHFLS$A_edu) <- c("Never attended school", "Elementary school", "Junior high school",
# "Senior high school", "Junior college", "University")
#
# CHFLS$R_health <- ordered(as.character(CHFLS$R_health), levels = c("poor", "not good",
# "fair", "good", "excellent"))
# levels(CHFLS$R_health) <- c("Poor", "Not good", "Fair", "Good", "Excellent")
#
# CHFLS$R_happy <- ordered(as.character(CHFLS$R_happy), levels = c("v unhappy", "not too",
# "relatively", "very"))
# levels(CHFLS$R_happy) <- c("Very unhappy", "Not too happy", "Relatively happy", "Very happy")
# ## End(Not run)
Run the code above in your browser using DataLab