I have a dataframe that contains monthly data on natural gas and oil in storage and CDD/HDD (as part of a larger class project on modeling gas and oil prices). I want to seasonally adjust these 4 columns since the data is seasonal. I am new to R and still am getting use to the logic.
I have tried this
install.packages("seasonal")
library(seasonal)
data%>%
mutate(`sNG Stored` <- seas(`NG Stored`,x11 = ""))
and the following error was thrown:
Error in `mutate()`:
ℹ In argument: ``sNG Stored` <- seas(`NG Stored`, x11 = "")`.
Caused by error in `x13_prepare()`:
! 'x' argument is not a time series.
According to documentation, the function
seasonal::seas()
takes asx
one of the following types of objects:ts
,mts
, or a list ofts
objects. Based on the error you report, the datafreame columnNG Stored
is not a time series object. For theseas()
function to run properly, the columnNG Stored
needs to be converted to either ats
ormts
. Your question didn't supply any data, so I created some toy data to illustrate one possible conversion process.Now the dataframe should be ready to accept the
seas()
function. The baseR
functionsstr()
andclass()
are helpful for diagnosing these kinds of issues.