I used the STL function in the {stats} package to seasonally detrend some time series data.
I would now like the results exported to csv, but when I try
write.csv(mySTLdata, "mySTLdata.csv")
I get the error
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
cannot coerce class ""stl"" to a data.frame
If I try to just convert the STL to a data.frame, it again tells me it cannot be coerced into one.
Any ideas on how I can get this out of the R environment for use elsewhere?
Going to leave this for anyone else who needs it in the future, but I figured it out.
To coerce an stl class into a data.frame, simply:
mySTLdata.DF <- as.data.frame(mySTLdata$time.series)
I was leaving off the $time.series part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.