I have a CSV file with a date column and a price column.
I am trying to convert it to xts format so that I can eventually use the aggregatets function. However when I try to run the following code:
mydata_xts=xts(mydata, order.by=as.POSIXct(mydata$Date, format="%d%/m/%y %H:%M"))
I receive this error:
Error in xts(mydata, order.by = as.POSIXct(mydata$Date, format = "%d%/m/%y %H:%M"))
'order.by' cannot contain 'NA', 'NaN', or 'Inf'
I am sure my data does not have any missing or dud values. What I suspect to be the problem is the way Excel formats time.
Attached is some information about my data.
head(mydata)
Date Price
1 1/03/2018 0:30 62.07
2 1/03/2018 1:00 60.35
3 1/03/2018 1:30 57.16
4 1/03/2018 2:00 55.88
5 1/03/2018 2:30 58.19
6 1/03/2018 3:00 60.63
summary(mydata)
Date Price
1/03/2018 0:30 : 1 Min. : 14.46
1/03/2018 1:00 : 1 1st Qu.: 61.98
1/03/2018 1:30 : 1 Median : 63.77
1/03/2018 10:00: 1 Mean : 66.70
1/03/2018 10:30: 1 3rd Qu.: 69.86
1/03/2018 11:00: 1 Max. :136.21
(Other) :1481
Here is my Excel/csv file: https://imgur.com/a/QofdEZl