umx_explode_twin_names: Break twin variable names (BMI_T1, BMI_T2) into base variable...

umx_explode_twin_namesR Documentation

Break twin variable names (BMI_T1, BMI_T2) into base variable names (BMI, "_T", 1:2)

Description

Break names like Dep_T1 into a list of base names, a separator, and a vector of twin indexes. e.g.: c("Dep_T1", "Dep_T2", "Anx_T1", "Anx_T2") will become:

list(baseNames = c("Dep", "Anx"), sep = "_T", twinIndexes = c(1,2))

Usage

umx_explode_twin_names(df, sep = "_T")

Arguments

df

vector of names or data.frame containing the data

sep

text constant separating name from numeric 1:2 twin index.

Value

- list(baseNames, sep, twinIndexes)

See Also

[umx_paste_names()]

Other String Functions: umx, umx_explode(), umx_grep(), umx_names(), umx_paste_names(), umx_rot(), umx_str_chars(), umx_str_from_object(), umx_trim()

Examples

## Not run: 
require(umx)
data("twinData")
umx_explode_twin_names(twinData, sep = "")
umx_explode_twin_names(twinData, sep = NULL)

# Ignore this: just a single-character/single variable test case
x = round(10 * rnorm(1000, mean = -.2))
y = round(5 * rnorm(1000))
x[x < 0] = 0; y[y < 0] = 0
umx_explode_twin_names(data.frame(x_T1 = x, x_T2 = y), sep = "_T")
umx_explode_twin_names(data.frame(x_T11 = x, x_T22 = y), sep = "_T")
umx_explode_twin_names(c("x_T11", "x_T22"), sep = "_T")

## End(Not run)

tbates/umx documentation built on Dec. 14, 2024, 11:28 a.m.