Description Usage Arguments Details Value Examples
Partially collapse multiple columns into key-values pairs. Use super_gather()
when you have have multiple wide-form variables that you want to partially collapse,
but you want those gathered variables to stay in separate columns. Equivalent to
calling gather
separately for dataframes with the same key and
different values, and joining them column-wise back into one dataframe. Requires the common
key(s) to be spelled identically in names of columns to be gathered.
1 2 | super_gather(data, key = "key", key_names = NULL, value_names = NULL,
name_order, delim_nchar = 1)
|
data |
A data frame. |
key |
Name of new key column, as string. |
key_names |
Names of key levels present in column names to be gathered,
as character vector. Specify either this or |
value_names |
Names of value levels present in column names to be gathered,
as character vector. Specify either this or |
name_order |
Which identifier comes first in existing colnames? Used to assist in
identifying which columns to gather. Choose |
delim_nchar |
How many characters delimit between key and value names? Defaults to 1. |
Implements a strategy akin to calling gather
, separate
, and
spread
in succession. As a result, may coerce some columns to character
under the hood. Please pay attention to warnings.
A data frame, with all indicated columns gathered, but separate.
1 2 3 4 5 6 7 8 | data <- data.frame(id = 1:10,
value1_cond1 = "a",
value1_cond2 = "b",
value2_cond1 = 0L,
value2_cond2 = 1L)
super_gather(data, "condition", key_names = c("cond1", "cond2"), name_order = "value_first")
super_gather(data, "condition", value_names = c("value1", "value2"), name_order = "value_first")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.