powered by
Collapse columns by converting from a wide to a long format and returns the result along with tidyverse code used to generate it.
stackVars(.data, vars, key = "stack.variable", value = "stack.value")
stacked dataframe with tidyverse code attached
a dataframe to stack
a character vector of variables to stack
name of the new column for the stacked variables. "stack.variable" by default
name of the new column for the stacked values of the stacked. "stack.value" by default
Owen Jin
code
stacked <- stackVars(iris, vars = c("Species", "Sepal.Width"), key = "Variable", value = "Value") cat(code(stacked)) head(stacked)
Run the code above in your browser using DataLab