factorize: Create factor levels based on labels from a dataset

Description Usage Arguments Author(s)

Description

Reads labels from a reference dataset (usually imported from Stata, SPSS, or SAS) and applies them to the same variable in a label-free dataset to create a factor variable with levels and labels. By default, the levels will be sorted by their frequency in the dataset.

Usage

1
factorize(df, new_var, ...)

Arguments

df

main data frame containing the dataset to modify

new_var

string for the name of the new factor-ized variable you create.

ref_df

reference labelled data frame whose labels you want to use

var

string containing the variable name you want to change to a factor

Author(s)

Laura Hughes, laura.d.hughes@gmail.com


flaneuse/svywrangler documentation built on May 24, 2019, 2:49 p.m.