It really depends on what you want to do with the data.
1) plot for example, if your objective is simply to plot it then "ts"
class is not a good fit since it is not good at representing dates. Try this instead where we have defined test vector for sales
and tt
in the Note at the end.
library(zoo)
z <- zoo(sales, tt)
plot(z)
2) acf If you want to compute the autocorrelation function then using the plain vector sales
or ts(sales)
would be fine:
acf(sales)
3) StructTS If you want to fit a structural time series using StructTS
then you will need to decide on the length of a cycle, i.e. does it repeat every week? quarter? year?. Typically an annual cycle is appropriate for sales but, in general, you will need two complete cycles to do anything so you don't really have enough data for that.
4) monthly/quarterly If you are willing to reduce it to monthly or quarterly data then you could use ts
but you only have 20 points for monthly or 7 for quarterly. Here we have used the last point in each month:
library(zoo)
z <- zoo(sales, tt)
zm <- aggregate(z, as.yearmon, tail, 1)
tsm <- as.ts(zm)
tsm
giving:
Jan Feb Mar Apr May Jun Jul Aug
2016 3.258097 3.931826 4.356709 4.644391 4.867534 5.049856 5.204007 5.342334
2017 5.828946 5.897154 5.968708 6.030685 6.093570 6.150603 6.204558 6.257668
Sep Oct Nov Dec
2016 5.459586 5.564520 5.659482 5.749393
2017
5) weekly Another thing you could consider would be to use weekly series by just using Saturday, for example:
library(zoo)
z <- zoo(sales, tt)
zw <- z[weekdays(time(z)) == "Saturday"]
Note: We used this dummy data:
set.seed(123)
tt <- seq(as.Date("2016-01-01"), as.Date("2017-08-31"), "day")
tt <- tt[! weekdays(tt) == "Sunday"]
n <- length(tt)
sales <- log(1:n)