Re: [R] Selecting ranges of dates from a dataframe

2011-03-11 Thread David Winsemius
On Mar 11, 2011, at 8:41 AM, Benjamin Stier wrote: Hi Francisco, Thanks for your solution. It runs pretty fast compared to my for loop. Here is a comparison of system.time(): system.time(splitVals <- by(serv, dates, aggregateDf )) user system elapsed 1.129 0.218 1.348 system.time(

Re: [R] Selecting ranges of dates from a dataframe

2011-03-11 Thread Benjamin Stier
Hi Francisco, Thanks for your solution. It runs pretty fast compared to my for loop. Here is a comparison of system.time(): system.time(splitVals <- by(serv, dates, aggregateDf )) user system elapsed 1.129 0.218 1.348 system.time(... my long for loop...) user system elapsed 276.

Re: [R] Selecting ranges of dates from a dataframe

2011-03-11 Thread David Winsemius
On Mar 10, 2011, at 8:23 AM, Benjamin Stier wrote: Hello list! I have a data.frame which looks like this: serv datum op.read op.write read write 1 2011-01-29 10:00:00 00 0 0 2 2011-01-29 10:00:01 00 0 0 3 2011-01-29 10:00:02 0

Re: [R] Selecting ranges of dates from a dataframe

2011-03-10 Thread Francisco Gochez
Benjamin, A more elegant "R-style" solution would be to use one of R's "apply"/aggregation routines, of which there are many. For example, the "by" function can split a data.frame by some factor/categorical variable(s), and then apply a function to each "slice". The result can then be pieced back

[R] Selecting ranges of dates from a dataframe

2011-03-10 Thread Benjamin Stier
Hello list! I have a data.frame which looks like this: > serv datum op.read op.write read write 1 2011-01-29 10:00:00 00 0 0 2 2011-01-29 10:00:01 00 0 0 3 2011-01-29 10:00:02 00 0 0 4 2011-01-29 10:00:03