Re: [R] Coversion from yearly to weekly data

2013-03-08 Thread PIKAL Petr
tor, test$Day, 2012, sep=".") Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Nico Met > Sent: Friday, March 08, 2013 4:16 PM > To: R help > Subject: [R] Coversion from yearly to week

Re: [R] Coversion from yearly to weekly data

2013-03-08 Thread Rui Barradas
Hello, Something like this? sp <- split(test, test$Data) res <- do.call(rbind, lapply(sp, function(x){ Week <- (seq_len(nrow(x)) %/% 7) + 1 aggregate(Value ~ Data + Week, data = x, FUN = mean)})) rownames(res) <- seq_len(nrow(res)) res Hope this helps, Rui Barradas Em 08-03-

[R] Coversion from yearly to weekly data

2013-03-08 Thread Nico Met
Dear all, I have a big data matrix and I want to convert those data into weekly basis which means 7 days needs to be avaraged and aggregate a single value > dput(test) structure(list(locid = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,