Learn R Programming

umx (version 1.9.1)

umx_make_bin_cont_pair_data: Make pairs of bin & continuous columns to represent censored data

Description

Takes a dataframe of left-censored variables (vars with a floor effect) and does two things to it: 1. It creates new binary (1/0) copies of each column (with the suffix "bin"). These contain 0 where the variable is below the minimum and NA otherwise. 2. In each existing variable, it sets all instances of min for that var to NA

Usage

umx_make_bin_cont_pair_data(data, vars = NULL, suffixes = NULL)

Arguments

data

A data.frame to convert

vars

The variables to process

suffixes

Suffixes if the data are family (wide, more than one persona on a row)

Value

- copy of the dataframe with new binary variables and censoring

References

- https://github.com/tbates/umx, https://tbates.github.io, http://openmx.ssri.psu.edu

See Also

Other Data Functions: umxCovData, umxFactor, umxHetCor, umxPadAndPruneForDefVars, umx_as_numeric, umx_cont_2_quantiles, umx_cov2raw, umx_long2wide, umx_lower2full, umx_make_MR_data, umx_make_TwinData, umx_make_fake_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_wide2long, umx

Examples

Run this code
# NOT RUN {
df = umx_make_bin_cont_pair_data(mtcars, vars = c("mpg"))
str(df)
df[order(df$mpg), c(1,12)]
# Introduce a floor effect
tmp = mtcars; tmp$mpg[tmp$mpg<=15]=15
tmp$mpg_T1 = tmp$mpg_T2 = tmp$mpg
df = umx_make_bin_cont_pair_data(tmp, vars = c("mpg"), suffixes = c("_T1", "_T2"))
df[order(df$mpg), 12:15]
# }

Run the code above in your browser using DataLab