From felix at nfrac.org  Fri Jul 31 09:27:06 2009
From: felix at nfrac.org (Felix Andrews)
Date: Fri, 31 Jul 2009 17:27:06 +1000
Subject: [Rd] rowSums, rowMean and rowCumSums?
In-Reply-To: <F6AF81E1-11C1-4343-B20D-1979B6945F38@gmail.com>
References: <F6AF81E1-11C1-4343-B20D-1979B6945F38@gmail.com>
Message-ID: <94730b8a0907310027q57fe1d08u30147156a0e00bec@mail.gmail.com>

Hi,
you can compute cumsums for each row with
t(apply(x, 1, cumsum))
As this is a simple, direct implementation, I see no reason to make it
a named function.

Cheers
-Felix


2009/7/31 Christophe Dutang <dutangc at gmail.com>:
> Dear list,
>
> Don't you think it could be useful to have in R base a function
> rowCumSums, that compute cumulative sums for each row of a matrix?
>
> My implementation of rowCumSums is
>
> rowCumSums <- function(x) t(mapply(function(row)cumsum(x[row,]),
> 1:NROW(x)))
>
> I'm sure it can be improved to have other arguments like na.rm or dims.
>
> Is there any hope to have this function in R?
>
> Christophe
>
> --
> Christophe Dutang
> Ph.D. student at ISFA, Lyon, France
> website: http://dutangc.free.fr
>
>
>
>
>
>
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Felix Andrews / ???
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 1670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/



[Rd] rowSums, rowMean and rowCumSums?
Felix Andrews