| umx_stack {umx} | R Documentation |
Stack data like stack() does, with more control.
Description
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.
Usage
umx_stack(x, select, passalong, valuesName = "values", groupName = "ind")
Arguments
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") |
Value
long-format dataframe
See Also
Other Data Functions:
noNAs(),
prolific_anonymize(),
prolific_check_ID(),
prolific_read_demog(),
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_merge_randomized_columns(),
umx_polychoric(),
umx_polypairwise(),
umx_polytriowise(),
umx_read_lower(),
umx_rename(),
umx_reorder(),
umx_score_scale(),
umx_select_valid(),
umx_strings2numeric(),
umx
Examples
# 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)