Change format from fpp2 to fpp3

I would like to receive an script in R to convert uschange dataset in fpp2 to us_change a tsibble object in fpp3. I have worked on it, without success. Thanks a lot. Agustin1


Referred here by Forecasting: Principles and Practice, by Rob J Hyndman and George Athanasopoulos

First, the fpp2::uschange data is already a tsibble object in the fpp3 package, available as fpp3:us_change.

Second, you can convert any ts object to tsibble format using as_tsibble(). For example

library(fpp3)
as_tsibble(fpp2::uschange)
#> # A tsibble: 935 x 3 [1Q]
#> # Key:       key [5]
#>      index key          value
#>      <qtr> <chr>        <dbl>
#>  1 1970 Q1 Consumption  0.616
#>  2 1970 Q2 Consumption  0.460
#>  3 1970 Q3 Consumption  0.877
#>  4 1970 Q4 Consumption -0.274
#>  5 1971 Q1 Consumption  1.90 
#>  6 1971 Q2 Consumption  0.912
#>  7 1971 Q3 Consumption  0.795
#>  8 1971 Q4 Consumption  1.65 
#>  9 1972 Q1 Consumption  1.31 
#> 10 1972 Q2 Consumption  1.89 
#> # … with 925 more rows

Created on 2022-06-07 by the reprex package (v2.0.1)

This topic was automatically closed 21 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.