gather-rows
Gathers rows in wide format to long format.
Last updated
Gathers rows in wide format to long format.
Last updated
Reshapes the datatable from wide to long. Reduces the number of columns, and increases the number of rows.
See http://www.milanor.net/blog/reshape-data-r-tidyr-vs-reshape2 for more information about reshaping data.
See Example below for details.
This adaptor is the opposite of spread-rows, which reshapes from long to wide format.
data
: The input datatable in wide format.
columns
: All of the columns you want to keep as they are, which are not getting reshaped.
All other columns (that are not listed in this argument) will be reshaped so their column names become the value of 'key' and their values become the values of 'value'.
The values in columns
will become repeated in each new row they represent for the reshaped portions of the datatable. If there are three columns being turned into keys, then each row of "columns" values will now occur in three rows instead of one.
key
: The name of the column that will contain the keys (i.e. this column will contain the old column names).
value
: The name of the column to which values are added (i.e. this column will contain the values that were in the rows/cells in the old columns).
output
: The reshaped datatable with columns
columns, key
column, and value
column.
Instead of having a separate column for each metric, have a column called 'metric name' and another called 'metric value' to facilitate certain kinds of data processing or data visualisations.