I am currently doing research on soil moisture and have to get hourly and daily means from my time series data.
When I convert the dataframe into an xts object, the time series changes and I can't figure out why.
The data in the data frame looks like this:
time MC temp
1 2018-06-27 11:30:00 17.1 15.8
2 2018-06-27 11:45:00 17.0 15.8
3 2018-06-27 12:00:00 17.0 15.8
4 2018-06-27 12:15:00 17.0 15.9
5 2018-06-27 12:30:00 17.2 15.9
6 2018-06-27 12:45:00 17.0 16.0
But when I convert it, the time stamp begins at 2018-01-09 00:00 and proceeds to make 5 min time increments. This is the code I am using:
sm_xts <- xts(sm.data[,2:3], as.Date(sm.data$time))
sm_zoo <- read.zoo(sm.data, index.column = 1)
dat_xts <- as.xts(sm_zoo)
I have already converted the time stamp to a as.POSIXct
class and checked for duplicates in my time series.
> anyDuplicated(sm.data$time)
[1] 0