Learn R Programming

umx (version 1.2.5)

umx_cont_2_ordinal: umx_cont_2_ordinal

Description

Recode a variable into n-quantiles (default = deciles (10 levels)). It returns an mxFactor, with the levels labeled with the max value in each quantile (i.e., open on the left-side).

Usage

umx_cont_2_ordinal(var, nlevels = 10, type = c("mxFactor", "ordered",
  "unordered"), verbose = FALSE)

Arguments

var
a variable to recode as ordinal
nlevels
how many bins or levels (at most) to use (default = 10 i,e deciles)
type
what to return (Default is "mxFactor") options include "ordered" and "unordered")
verbose
report the min, max, and decile cuts used (default = FALSE)

Value

Details

Note: Redundant bins are merged. i.e., if the same score identifies all deciles up to the fourth, then these will be merged into one level.

References

- https://github.com/tbates/umx, https://tbates.github.io

See Also

Other Data Functions: umxCovData, umxFactor, umxHetCor, umxPadAndPruneForDefVars, umx_as_numeric, umx_cov2raw, umx_fake_data, umx_lower2full, umx_make_bin_cont_pair_data, umx_merge_CIs, umx_read_lower, umx_reorder, umx_residualize, umx_round, umx_scale_wide_twin_data, umx_scale, umx_swap_a_block, umx

Examples

Run this code
x = umx_cont_2_ordinal(rnorm(10000), verbose = TRUE)
x = umx_cont_2_ordinal(rep(0:10, 10), verbose = TRUE)
levels(x)
str(umx_cont_2_ordinal(rnorm(10000), nlevels = 4, verbose = TRUE))

Run the code above in your browser using DataLab