Reshaping dataset from wide to long or from long to wide
Usage
reshape_data(
data,
data_to = c("long", "wide"),
cols,
names_to = "name",
values_to = "value",
names_from = "name",
values_from = "value"
)
Arguments
- data
a dataset to reshape
- data_to
whether the target dataset is
long
orwide
- cols
columns to gather together (for wide to long)
- names_to
name for new column containing old names (for wide to long)
- values_to
name for new column containing old values (for wide to long)
- names_from
column to spread out (for long to wide)
- values_from
values to be put in the spread columns (for long to wide)