3.2 tsibble
objects
The tsibble package extends the tidyverse to temporal data and tsibble
(or tbl_ts
) objects are the way time-series data are stored in that package. There are many ways that you can transform a tsibble
object into a matrix with each row being an observed time series.
library(tidyverse)
library(tsibble)
<- tourism %>% as_tibble %>% tidyr::spread(Quarter, Trips)
dat <- as.matrix(dat[, -1*(1:3)]) dat.matrix