Re: [R] sequential sum of a vector...

2008-07-23 Thread Patrizio Frederic
try this colSums(matrix(x,8)) regards, PF +- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 |

Re: [R] sequential sum of a vector...

2008-07-23 Thread Shubha Vishwanath Karanth
... Thanks, shubha From: Jorge Ivan Velez [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2008 8:59 PM To: Shubha Vishwanath Karanth Cc: [EMAIL PROTECTED] Subject: Re: [R] sequential sum of a vector... Dear Shubha, Try this: x=1:80 tapply(x,rep(1:10

Re: [R] sequential sum of a vector...

2008-07-23 Thread Marc Schwartz
on 07/23/2008 09:03 AM Shubha Vishwanath Karanth wrote: Hi R, Let, x=1:80 I want to sum up first 8 elements of x, then again next 8 elements of x, then again another 8 elements. So, my new vector should look like: c(36,100,164,228,292,356,420,484,548,612) I used:

Re: [R] sequential sum of a vector...

2008-07-23 Thread Richard . Cotton
x=1:80 I want to sum up first 8 elements of x, then again next 8 elements of x, then again another 8 elements. So, my new vector should look like: c(36,100,164,228,292,356,420,484,548,612) I used: aggregate(x,list(rep(1:10,each=8)),sum)[-1] or

Re: [R] sequential sum of a vector...

2008-07-23 Thread Jorge Ivan Velez
Dear Shubha, Try this: x=1:80 tapply(x,rep(1:10,each=8),sum) 1 2 3 4 5 6 7 8 9 10 36 100 164 228 292 356 420 484 548 612 HTH, Jorge On Wed, Jul 23, 2008 at 10:03 AM, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Let, x=1:80 I want to sum up first

Re: [R] sequential sum of a vector...

2008-07-23 Thread William Revelle
At 7:33 PM +0530 7/23/08, Shubha Vishwanath Karanth wrote: Hi R, Let, x=1:80 I want to sum up first 8 elements of x, then again next 8 elements of x, then again another 8 elements. So, my new vector should look like: c(36,100,164,228,292,356,420,484,548,612) I used:

Re: [R] sequential sum of a vector...

2008-07-23 Thread Henrique Dallazuanna
Maybe: tapply(x, gl(10, 8), sum) or unlist(lapply(split(x, gl(10, 8)), sum)) On Wed, Jul 23, 2008 at 11:03 AM, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Let, x=1:80 I want to sum up first 8 elements of x, then again next 8 elements of x, then again another 8

Re: [R] sequential sum of a vector...

2008-07-23 Thread denise xifaras
  --- On Wed, 7/23/08, Patrizio Frederic [EMAIL PROTECTED] wrote: From: Patrizio Frederic [EMAIL PROTECTED] Subject: Re: [R] sequential sum of a vector... To: Shubha Vishwanath Karanth [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Wednesday, July 23, 2008, 8:30 AM try this colSums(matrix(x,8