Description Usage Arguments Value See Also Examples
View source: R/long_wide.R View source: R/wider_dt.R
Analogous function for pivot_wider
in tidyr.
1 2 3 4 5 6 7 |
data |
data.table |
group_to_keep |
The unchanged group in the transformation.
Could use integer vector, character vector or regular expression(to match
the column names). If |
name_to_spread |
Chracter.One column name of class to spread |
value_to_spread |
Chracter.One column name of value to spread.
If |
fill |
Value with which to fill missing cells. Default uses |
data.table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | stocks = data.frame(
time = as.Date('2009-01-01') + 0:9,
X = rnorm(10, 0, 1),
Y = rnorm(10, 0, 2),
Z = rnorm(10, 0, 4)
) %>%
longer_dt(time) -> longer_stocks
longer_stocks
longer_stocks %>%
wider_dt("time","variable","value")
longer_stocks %>%
mutate_dt(one = 1) %>%
wider_dt("time","variable","one")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.