rename.sdf: Modify Variable Names

View source: R/rename.sdf.R

rename.sdfR Documentation

Modify Variable Names

Description

Renames variables in an edsurvey.data.frame, a light.edsurvey.data.frame, or an edsurvey.data.frame.list. This function often is used when users want to conduct a gap analysis across years but variable names differ across two years of data.

Usage

rename.sdf(x, oldnames, newnames, avoid_duplicated = TRUE)

Arguments

x

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

oldnames

a character vector of old variable names

newnames

a character vector of new variable names to replace the corresponding old names

avoid_duplicated

a logical value to indicate whether to avoid renaming the variable if the corresponding new name already exists in the data. Defaults to TRUE.

Details

All variable names are coerced to lowercase to comply with the EdSurvey standard.

Value

an object of the same class as x with new variable names

Author(s)

Trang Nguyen

See Also

gap

Examples

## Not run: 
usaG4.15 <- readTIMSS(path="~/TIMSS/2015", "usa", 4)
usaG4.15.renamed <- rename.sdf(x=usaG4.15,
                               oldnames=c("itsex", "mmat"),
                               newnames=c("gender", "math_overall"))
lm1 <- lm.sdf(formula=math_overall ~ gender, data = usaG4.15.renamed)
summary(lm1)

## End(Not run)

EdSurvey documentation built on June 27, 2024, 5:10 p.m.