stackVars {iNZightTools} | R Documentation |
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")
.data |
a dataframe to stack |
vars |
a character vector of variables to stack |
key |
name of the new column for the stacked variables. "stack.variable" by default |
value |
name of the new column for the stacked values of the stacked. "stack.value" by default |
stacked dataframe with tidyverse code attached
Owen Jin
stacked <- stackVars(iris, vars = c("Species", "Sepal.Width"),
key = "Variable", value = "Value")
cat(code(stacked))
head(stacked)