Hi mac,

Try

N <- 6000
x <- sample(1:0, N, TRUE)
tapply(x, rep(1:(N/60), each = 60), sum)

HTH,
Jorge


On Sat, May 21, 2011 at 1:59 PM, andyjmac <> wrote:

> Dear members,
>
> I apologize for the relatively simple request, but I couldn't find exactly
> what I was looking for. I have a binary vector [1,0] representing
> presence/absence at 1 second intervals over length(N). I would like to
> convert this to a new time series vector with N/60 elements that represent
> the sum of x/minute.
>
> In other words, I'd like to get from:
>
> e.g. x = [1,0,1,1,0,1,1,1,0,0,0,1,0,1, ... ] *N=6,000
>
> to
>
> e.g. x = [35, 40, 10, 29, ... ] *where each element has min=0 and max=60
> over length N=100
>
> Thanks so much,
>
> mac
> Kyoto University, Japan
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/convert-binary-vector-to-time-series-of-sum-x-minute-tp3540942p3540942.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to