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