-1

I am quite new to R and I am looking for some help:

I have the following dataframe:

    Time    Power

00:00:00    176,7703
00:01:00    156,5946
00:02:00    183,2568
00:03:00    179,2027
00:04:00    193,3514
00:05:00    153,5946
00:06:00    174,7162
00:07:00    180,2027
00:08:00    162,3108
00:09:00    189,0135
00:10:00    188,3919
00:11:00    178,1081
00:12:00    205,1622
00:13:00    219,4324
00:14:00    214,4865
00:15:00    221,6216
00:16:00    264,0405
00:17:00    218,1351

Now I am looking for a possibility to get the mean value for every 5 minutes. e.g.:

Time    Power
00:00   176,7703
00:05   173,20002
00:10   178,92702
00:15   201,11622

How can i program this with R? Any help would be appreciated.

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
TheOne
  • 1
  • Have you tried solutions provided on SO, like [this one](http://stackoverflow.com/questions/22203493/aggregate-1-minute-data-into-5-minute-average-data)? – Roman Luštrik May 14 '17 at 15:16

1 Answers1

0

assuming data is stored in a dataframe called "df" you could just do something like

tapply(df$Power[-1], (seq_along(df$Power[-1])-1) %/% 5, mean)

this would give you the means of minute 00:01:00 to 00:05:00, 00:06:00 to 00:10:00 and so on.

        0        1        2        3 
 173.2000 178.9270 207.7622 241.0878 
Larusson
  • 267
  • 3
  • 21