Learn R Programming

surveytable (version 0.9.6)

var_collapse: Collapse factor levels

Description

Collapse two or more levels of a factor variable into a single level.

Usage

var_collapse(vr, newlevel, oldlevels)

Value

Survey object

Arguments

vr

factor variable

newlevel

name of the new level

oldlevels

vector of old levels

See Also

Other variables: var_all(), var_any(), var_case(), var_copy(), var_cross(), var_cut(), var_not()

Examples

Run this code
set_survey(namcs2019sv)
tab("PRIMCARE")
var_collapse("PRIMCARE", "Unknown if PCP", c("Blank", "Unknown"))
tab("PRIMCARE")

Run the code above in your browser using DataLab