I noticed that Gabor's interpretation of your desires was the opposite
of what mine was, and also that you were thinking tapply might be a
useful strategy. Here is a tapply implementation that lets you choose:
x$wanted <- c(0,-diff(x$status))
x$dif.tm <- c(diff(x$time),NA)
sum(x[x$wanted==1,
On Jul 3, 2009, at 9:21 AM, rory.wins...@gmail.com wrote:
Hi
I have a dataset that looks like this (dput'd below):
head(x, 20)
time status
1 2009-07-02 10:32:37 1
2 2009-07-02 10:32:43 0
3 2009-07-02 10:32:43 1
4 2009-07-02 10:32:44 0
5 2009-07-02 10:32:44 1
6 2009-07-02 10:32:48 0
7 2009-
Try this:
> d <- diff(DF$time)
> d[rep(c(FALSE, TRUE), length = length(d))]
Time differences in secs
[1] 0 0 0 10 1 6 23 2 1
> d[rep(c(TRUE, FALSE), length = length(d))]
Time differences in secs
[1] 6 1 4 6 0 2 4 8 1 0
On Fri, Jul 3, 2009 at 9:21 AM, wrote:
> Hi
>
> I have a dataset that
Hi
I have a dataset that looks like this (dput'd below):
> head(x, 20)
time status
1 2009-07-02 10:32:37 1
2 2009-07-02 10:32:43 0
3 2009-07-02 10:32:43 1
4 2009-07-02 10:32:44 0
5 2009-07-02 10:32:44 1
6 2009-07-02 10:32:48 0
7 2009-07-02 10:32:48 1
8 2009-07-02 10:32:54 0
9 2009-07-02 10:33:04
4 matches
Mail list logo