Skip to content

splitting time vector into days

3 messages · Alexy Khrabrov, stephen sefick, jim holtman

#
Greetings -- I have a dataframe a with one element a vector, time, of  
POSIXct values.  What's a good way to split the data frame into  
periods of a$time, e.g. days, and apply a function, e.g. mean, to some  
other column of the dataframe, e.g. a$value?

Cheers,
Alexy
#
?aggregate
?window.zoo
?rollapply

anyway have a look at package zoo
On Tue, Sep 9, 2008 at 3:25 PM, Alexy Khrabrov <deliverable at gmail.com> wrote:

  
    
#
Here is one way of doing it:
+     values=1:10)
$`20080908`
                dates values
1 2008-09-08 00:00:00      1
2 2008-09-08 07:00:00      2
3 2008-09-08 14:00:00      3
4 2008-09-08 21:00:00      4

$`20080909`
                dates values
5 2008-09-09 04:00:00      5
6 2008-09-09 11:00:00      6
7 2008-09-09 18:00:00      7

$`20080910`
                 dates values
8  2008-09-10 01:00:00      8
9  2008-09-10 08:00:00      9
10 2008-09-10 15:00:00     10
$`20080908`
[1] 2.5

$`20080909`
[1] 6

$`20080910`
[1] 9

        
On Tue, Sep 9, 2008 at 3:25 PM, Alexy Khrabrov <deliverable at gmail.com> wrote: