Issue with date in time series plot

Hi all,
I'm having some issues with my time series data.
In my excel, my date format is as follows (17/6/10), by dd/m/yy.
When I import my excel into R, its all fine, but when I transform the data into a time series, and when I check the cycle of the data, it seems to be wrong.

The codes that I used are as follow:
data=read.csv(file='ts3.csv',header = TRUE)
as.Date(data$Date)
gross<- data$Gross
datats<-ts(gross,start = c(17,6,10),frequency = 7)
View(data)
plot.ts(datats,main='Weekly gross of Toy Story 3',xlab='Day in terms of weeks', ylab='Gross')
abline(reg =lm(datats~time(datats)))
cycle(datats)

Where did I go wrong? is it the start=c() part, or the frequency? My dates are in daily data, for 90+ days, so should my freq=365?

In here, we can see that the start of the cycle is '6', where 17th June 2010 is a Thursday instead

Thanks in advance for all your kind help!


Here is a pic of my time series plot. The x-axis data is wrong as well.

Hi @Dixon,
Welcome to the RStudio Community Forum.

I suspect that your character strings from Excel are not being converted into "correct" dates by your code. Compare and contrast:

as.Date("17/6/10")
#> [1] "0017-06-10"
as.Date("17/6/10", format="%d/%m/%y")
#> [1] "2010-06-17"

Created on 2021-08-20 by the reprex package (v2.0.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.