[Rd] rowSums, rowMean and rowCumSums?

Felix Andrews felix at nfrac.org
Fri Jul 31 09:27:06 CEST 2009


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/



More information about the R-devel mailing list