; CC: r-help@r-project.org
> Subject: Re: [R] sequential sum
>
>
> On Feb 14, 2012, at 1:38 PM, Nordlund, Dan (DSHS/RDA) wrote:
>
> >> -Original Message-
> >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> >> project.org] On Behal
On Feb 14, 2012, at 1:38 PM, Nordlund, Dan (DSHS/RDA) wrote:
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of baccts
Sent: Tuesday, February 14, 2012 9:04 AM
To: r-help@r-project.org
Subject: [R] sequential sum
Dear R users,
I
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of baccts
> Sent: Tuesday, February 14, 2012 9:04 AM
> To: r-help@r-project.org
> Subject: [R] sequential sum
>
> Dear R users,
>
> I am trying to su
Dear R users,
I am trying to sum number that exist in another vector up to i, then
increment i and repeat.
Sorry. It's hard to explain but basically I am trying to do the following:
test <- c(1,2,3,4);
test2 <- c(3,5,6,7,2,8,8,4,4);
test3 <- c(10,20,30,40);
tmp <- 0;
for (i in 1:length(test)){
tmp
vioravis wrote on 12/06/2011 12:42:35 PM:
> I am trying to code the following excel formula in R.
>
> ab cResultFormula
> 1 10 0.1 #N/A
> IF(B2<20,NA(),C2+IF(ISERROR(D1),0,D1))
> 2 20 0.2 0.2
> IF(B3<20,NA
I am trying to code the following excel formula in R.
ab cResultFormula
1 10 0.1 #N/A
IF(B2<20,NA(),C2+IF(ISERROR(D1),0,D1))
2 20 0.2 0.2
IF(B3<20,NA(),C3+IF(ISERROR(D2),0,D2))
3 30
--- 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
16 matches
Mail list logo