I have a large data set that I am trying to reformat. Unfortunately, I cannot aggregate daily data.
dataset1_updated<- structure(list(X = 1:5, Time = structure(c(1L, 1L, 2L, 3L, 3L), .Label = c("7/29/11 10:29", "7/29/11 10:30", "7/29/11 10:32"
), class = "factor"), O3 = c(32.032608222367, 32.032608222367,
32.032608222367, 32.032608222367, 32.032608222367), SO2 = c(2.611,
2.605, 2.744, 2.767, 2.778), NO = c(0.081, 0.081, 0.081, 0.081,
0.081), NO2 = c(1.938, 1.912, 1.912, 1.896, 1.863), NOx = c(2.019,
1.993, 1.993, 1.977, 1.944)), .Names = c("X", "Time", "O3",
"SO2", "NO", "NO2", "NOx"), row.names = c(NA, 5L), class = "data.frame")
I convert the data set to xts object, and apply daily mean function, the results are "NA". Could you please tell me what is missing?
x <- as.xts(as.POSIXct(dataset1_updated$Time, format="%m/%d/%Y %H:%M"))
x_up<- apply.daily(x, colMeans)
write.csv(as.data.frame(as.matrix(x_up)), file="test")
thank you,