Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

umx_explode_twin_names

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()]

Examples

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")

umx

Structural Equation Modeling and Twin Modeling in R

v4.10.10
GPL-3
Authors
Timothy C. Bates [aut, cre] (<https://orcid.org/0000-0002-1153-9007>), Gillespie Nathan [wit], Michael Zakharin [wit], Brenton Wiernik [ctb], Joshua N. Pritikin [ctb], Michael C. Neale [ctb], Hermine Maes [ctb]
Initial release
2021-11-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.