0
$\begingroup$

I have sales data for 2018 and 2019. I would like to convert it to time series. The data does not have daily sales:

View(df)

Sales          Date 

75606         11/01/18

95620         16/01/18

55666         21/01/18

56270         29/01/18

45600         11/02/18

65620         18/02/18

50660         26/02/18

76200         10/03/18

75606         20/03/18

95620         27/03/18

55666         28/03/18

56270         29/03/18

45600         17/04/18

65620         24/04/18

50660         02/05/18

76200         16/05/18

And so on until 2019 December.

Here the problem is if I convert it to time series by using following code:

tsn <- ts(df[,1], start =c(2018, 1), frequency=12) 

It is considering only $1^{st}$ 12 rows The output will be having $1^{st}$ 12 values

So how do I convert the whole data into time series? Should I aggregate monthly wise and convert that into time series or is there any way to do?

$\endgroup$

2 Answers 2

0
$\begingroup$

This is an example of multi-parallel-time-series.

Example shared on github MultiParallelTimeSeries, believe that will be helpful.

$\endgroup$
1
  • $\begingroup$ I need in R Language $\endgroup$ Mar 3, 2020 at 11:25
0
$\begingroup$

Check the Date column type if it is a character you need to convert it into the date format and then change the dataframe to time series object using xts function from xts package.

library(lubridate) 
df$Date <- dmy(df$Date)
library(xts) #used to convert dataframe to ts object
tsdf<-xts(df,order.by=df$Date)
$\endgroup$
1
  • $\begingroup$ The data frame has converted to xts and zoo class. The data captured well for all the dates available. But I can't do ets arima models using this. How to proceed further $\endgroup$ Mar 4, 2020 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.