The xts object has time stamps to the second, so it will interpret the frequency of hourly data as 1/3600 and decompose() does not know how to handle frequencies less than 1. There are two choices.
- Redefine the object to have seasonality of 24 so it picks up the daily pattern (but not a weekly or annual pattern if they exist). It will make a mess of the time axis, but it will give you a decomposition. To do this, simply use
decompose(ts(xts.obj, frequency=24))
- A nicer approach, but slightly more work, would be to use the feasts package which uses tsibble objects.
library(feasts)
df <- tsbox::ts_tsibble(xts_obj)
decomp <- df %>% model(STL(Wind)) %>% components()
decomp %>% autoplot()
This will automatically identify that it is hourly data and the decomposition will show the daily, weekly and annual patterns (the latter only if the series is long enough).