Trouble with time series dates

The example you give isn't directly runable, (see reprex) so I can't say for certain if this works.

Date conversion

Try something like the following to convert the "Date" column to a Date class.


TomDO<- ts(Tom_Frost_Dissolved_Oxygen)
# Convert to Date class
TomDO$Date <- mdy(TomDO$Date)

autoplot(TomDO, ts.geom = 'ribbon', fill = 'blue')

Pivot the data longer

Maybe autoplot is getting messed up by the catgorical nature of the columns. Let's convert the data to a longer format. To do this it used to be melt or gather, but now it's pivot_longer.


TomDO <- tribble(~Top, ~Middle, ~Bottom, ~Date,
        12.55,   13.39,   9.55,    "3/9/15",
        6.8,     6.55,    0.36,    "3/31/15",
        7.22,    6.64,    6.01,    "4/13/15",
        7.22,    6.64,    6.01,    "4/13/15")
# Date class conversion
TomDO$Date <- mdy(TomDO$Date)
# Make long format data
pivoted_df <- pivot_longer(TomDO, cols=c("Top", "Middle", "Bottom"), names_to="Layer")
# plot!
autoplot(pivoted_df, ts.geom="ribbon")
# Error: Objects of type tbl_df/tbl/data.frame not supported by autoplot.

Huh... what kind of object is TomDO?

autoplot(ts(pivoted_df), ts.geom="ribbon")
# Error: Objects of type mts/ts/matrix not supported by autoplot.

Reproducible example needed.

Well.... we tried some thing and found some errors. Can you provide a reproducible example?