I have the following data:
df=data.frame(store=c('A','A','A','A','B','B','B','B'),
              Date=c('2017-01-01','2017-01-02','2017-01-03','2017-01-04','2017-01-01','2017-01-02','2017-01-03','2017-01-04'),
              sales=c('15','37','29','18','16','22','5','6'))
   
df 
store       Date sales
1     A 2017-01-01    15
2     A 2017-01-02    37
3     A 2017-01-03    29
4     A 2017-01-04    18
5     B 2017-01-01    16
6     B 2017-01-02    22
7     B 2017-01-03     5
8     B 2017-01-04     6
I would like to convert it into a time series format as below:
        Date  A  B
1 2017-01-01 15 16
2 2017-01-02 37 22
3 2017-01-03 29  5
4 2017-01-04 18  6
I need to run auto.arima(from forecast package) iteratively on time series A & B.Hence i require the data frame to be the ts format.