var_cut {surveytable}R Documentation

Convert numeric to factor

Description

Create a new categorical variable based on a numeric variable.

Usage

var_cut(newvr, vr, breaks, labels)

Arguments

newvr

name of the new factor variable to be created

vr

numeric variable

breaks

see cut()

labels

see cut()

Value

Survey object

See Also

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

Examples

set_survey(namcs2019sv)
var_cut("Age group"
, "AGE"
, c(-Inf, 0, 4, 14, 64, Inf)
, c("Under 1", "1-4", "5-14", "15-64", "65 and over"))
tab("Age group")

[Package surveytable version 0.9.4 Index]