--- 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
On Wed, Jul 23, 2008 at 4:03 PM, 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 elements. So, my new vector should look like:
>
> c(36,100,164,228,29
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 a
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:
aggregate(x,list(rep(1:10
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
> 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
>
> rowsum(x,group=r
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:
a
eying...
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
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
| fax:
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:
aggregate(x,list(rep(1:10,each=8)),sum)[-1]
or
rowsum(x,group=r
10 matches
Mail list logo