I get some data from different sensors including a timestamp every minute. For visualizing my data I would like to summarize every 10 values with mean.
My data looks like this:
Temp Humidity Pressure Time
1 21.9 66.1 1007.76 2017-07-24 18:13:02
2 21.9 66.2 1007.76 2017-07-24 18:14:05
3 21.9 66.2 1007.76 2017-07-24 18:15:02
4 22.0 65.8 1007.76 2017-07-24 18:16:02
5 22.0 66.1 1007.76 2017-07-24 18:17:02
6 22.0 66.2 1007.76 2017-07-24 18:18:02
7 22.0 66.1 1007.76 2017-07-24 18:19:02
8 22.0 66.3 1007.76 2017-07-24 18:20:02
9 22.0 66.3 1007.76 2017-07-24 18:21:02
10 22.0 66.3 1007.76 2017-07-24 18:22:02
11 22.0 66.0 1007.76 2017-07-24 18:23:02
# [...] about 1700 rows
I have a working code, but only for the numeric cols:
aggregate(df,list(rep(1:(nrow(df)%/%n+1),each=n,len=nrow(df))),mean)[-1];
That gives me what I want for the first three columns, which are numeric vectors. But for the time, which is of POSIXlt all I get is "2017-07-24 18:17:32" in every row. Does anyone know a solution for this? It wouldn't be a problem if I had to take the means of Time seperately.