Stack data like stack() does, with more control.
Operates like stack(), but can preserve ("passalong") other variables on each row,
and allows the user control over the values and group column names for ease of use.
umx_stack(x, select, passalong, valuesName = "values", groupName = "ind")
x |
a dataframe containing twin data. |
select |
The variables to stack (wide 2 long) |
passalong |
Variables to preserve on each row (e.g. age) |
valuesName |
The name for the new stacked column (default = "values") |
groupName |
The name for the column containing the grouping variable (default = "ind") |
long-format dataframe
Other Data Functions:
noNAs(),
umxFactor(),
umxHetCor(),
umx_as_numeric(),
umx_cont_2_quantiles(),
umx_lower2full(),
umx_make_MR_data(),
umx_make_TwinData(),
umx_make_fake_data(),
umx_make_raw_from_cov(),
umx_polychoric(),
umx_polypairwise(),
umx_polytriowise(),
umx_read_lower(),
umx_read_prolific_demog(),
umx_rename(),
umx_reorder(),
umx_score_scale(),
umx_select_valid(),
umx
# Base-R stack function
df = stack(mtcars, select = c("disp", "hp"), drop=FALSE)
# umx_stack, with additional variables passed along
df= umx_stack(mtcars, select= c("disp", "hp"), passalong= "mpg")
str(df) # ind is a factor, with levels select
ggplot2::qplot(x = mpg, y= values, color=ind, data = df)
df= umx_stack(mtcars, select= c("disp", "hp"), passalong= "mpg")
ggplot2::qplot(x = mpg, y= values, group="ind", data = df)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.