Learn R Programming

umx (version 1.9.1)

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") -> list(baseNames = c("Dep"), 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

Other String Functions: umx_explode, umx_grep, umx_rot, umx_trim

Examples

Run this code
# NOT RUN {
require(umx)
data("twinData")
umx_explode_twin_names(twinData, sep = "")
# 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")
# }

Run the code above in your browser using DataLab