# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab