Change ts object to a tsibble one

Hi guys,

Not really sure how to do an minimal example about my issue, I would like to change a ts object to a tsibble one with my particular csv file,
Some help would be appreciated:

library(fable)
library(readxl)
library(tidyverse)

data <- read_xlsx("Airline Passengers, Australia, 2010-2019.xlsx")
data <- data$...4
data <- data[2:length(data)]

data_time_s <- ts(
value = data,
start = 1949,
end = 1960,
frequency = 12
) %>%
as_tsibble()

Maybe there is other really simple way to do that....

Best
Lucas

Given a time series object, it's easy to create a tsibble, as the example below from help(as_tsibble) illustrates.

suppressPackageStartupMessages({
  library(fpp3)
})

class(AirPassengers)
#> [1] "ts"
ap_tib <- as_tsibble(AirPassengers)
ap_tib
#> # A tsibble: 144 x 2 [1M]
#>       index value
#>       <mth> <dbl>
#>  1 1949 Jan   112
#>  2 1949 Feb   118
#>  3 1949 Mar   132
#>  4 1949 Apr   129
#>  5 1949 May   121
#>  6 1949 Jun   135
#>  7 1949 Jul   148
#>  8 1949 Aug   148
#>  9 1949 Sep   136
#> 10 1949 Oct   119
#> # … with 134 more rows

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.