Description Usage Arguments Examples
Extension of 'tidyr::spread' when there is a key with multiple values. Same purpose as Stata's 'reshape' wide.
1 | spread_multivalue(data, key, values, sep = "")
|
data |
a data frame |
key |
key, a string |
values |
A selection of columns. If empty, all variables are selected. You can supply bare variable names, select all variables between x and z with x:z, exclude y with -y. For more options, see the dplyr::select() documentation. |
sep |
separator to use between key and values |
1 2 3 4 5 6 7 8 9 10 11 | scores <- data.frame(
id = LETTERS[1:5],
age2000 = 11:15,
age2010 = 21:25,
scores2000 = 96:100,
scores2010 = 100:96)
# gather_multivalue(scores, "year", -id)
scores_long <- gather_multivalue(scores, "year", age2000:scores2010)
spread_multivalue(scores_long, "year", c(age, scores))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.