Learn R Programming

EdSurvey (version 4.0.7)

recode.sdf: Recode Levels Within Variables

Description

Recodes variables in an edsurvey.data.frame, a light.edsurvey.data.frame, or an edsurvey.data.frame.list.

Usage

recode.sdf(x, recode)

Value

an object of the same class as x with the recode added to it

Arguments

x

an edsurvey.data.frame, a light.edsurvey.data.frame, or an edsurvey.data.frame.list

recode

a list of recoding rules. See Examples for the format of recoding rules.

Author

Trang Nguyen and Paul Bailey

Examples

Run this code
if (FALSE) {
# filepath argument will vary by operating system conventions
usaG4.15 <- readTIMSS(path="~/TIMSS/2015", "usa", 4)
d <- getData(usaG4.15, "itsex")
summary(d) #show details: MALE/FEMALE
usaG4.15 <- recode.sdf(usaG4.15,
                       recode = list(itsex=list(from=c("MALE"),
                                                to=c("BOY")),
                                     itsex=list(from=c("FEMALE"),
                                                to=c("GIRL"))))

d <- getData(usaG4.15, "itsex") #apply recode
summary(d) #show details: BOY/GIRL
}

Run the code above in your browser using DataLab