Learn R Programming

umx (version 4.20.0)

umx_wide2long: Change data family data from wide (2 twins per row) to long format.

Description

Just detects the data columns for twin 1, and twin 2, then returns them stacked on top of each other (rbind) with the non-twin specific columns copied for each as well.

*Note*, zygosity codings differ among labs. One scheme uses 1 = MZFF, 2 = MZMM, 3 = DZFF, 4 = DZMM, 5 = DZOS or DZFM, 6 = DZMF, with 9 = unknown, and then 50, 51,... for siblings.

Typically, OS twins are ordered Female/Male.

Usage

umx_wide2long(data, sep = "_T", verbose = FALSE)

Value

- long-format dataframe

Arguments

data

a dataframe containing twin data.

sep

the string between the var name and twin suffix, i.e., var_T1 = _T

verbose

Report the non-twin and twin columns (default = FALSE).

See Also

[reshape()], [umx_merge_randomized_columns()], [umx_select_valid()]

Other Twin Data functions: umx_long2wide(), umx_make_TwinData(), umx_make_twin_data_nice(), umx_residualize(), umx_scale_wide_twin_data(), umx

Examples

Run this code
long = umx_wide2long(data = twinData, sep = "")
long = umx_wide2long(data = twinData, sep = "", verbose = TRUE)
str(long)
str(twinData)

Run the code above in your browser using DataLab