## Example 1:
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)
)
stocks
stocks %>%
longer_dt(time)
stocks %>%
longer_dt("ti")
# Example 2:
library(tidyr)
billboard %>%
longer_dt(
-"wk",
name = "week",
value = "rank",
na.rm = TRUE
)
# or use:
billboard %>%
longer_dt(
artist,track,date.entered,
name = "week",
value = "rank",
na.rm = TRUE
)
# or use:
billboard %>%
longer_dt(
1:3,
name = "week",
value = "rank",
na.rm = TRUE
)