edu_compile: Compile education across sources

View source: R/edu-funcs.R

edu_compileR Documentation

Compile education across sources

Description

Compiles education from participant, mother or father depending on source availability. Made for ease of testing and reporting education SES of family

Usage

edu_compile(data, participant, mother, father)

Arguments

data

MOAS-like data.frame

participant

unquoted column of 4 category education for participant

mother

unquoted column of 4 category education for participant's mother

father

unquoted column of 4 category education for participant's father

Value

dataframe with three new columns

See Also

Other edu_functions: edu_compute(), edu_factorise(), edu_levels2name(), edu_levels(), edu_reduce(), edu_to_years()

Examples


edu <- data.frame(
    edu4 = c("3", "High school", 1, NA,
         "University/University college (> 4 years)", NA, 
          "University/University college (< 4 years)"),
    edu9 = c(7,7,8,NA,"Primary school (6 years)",5, 9),
    edu_years = c(NA, 12, 9, NA, 19, 19, NA),
    mother = c("3", "High school", 1, NA,
               "University/University college (> 4 years)",
               "University/University college (> 4 years)", 
               "University/University college (< 4 years)"),
    father = c(7,7,8,4,"Primary school (6 years)",5, 10),
    stringsAsFactors = FALSE
    )
 
 library(dplyr)
 edu %>% 
     mutate(
        mother = ifelse(mother == "3", NA, mother),
        mother = edu4_factorise(mother),
        father = edu9_reduce(edu9_factorise(father))
     ) %>% 
     edu_compile(
        participant = edu4,
        mother = mother,
        father = father
        )

LCBC-UiO/Questionnaires documentation built on July 18, 2023, 6:45 p.m.