Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

Re: [R] apply and arrays

Uwe Ligges

2005-07-25

Replies:

Laura Holt wrote:

> Hi R!
>
> I have a 3 dimensional array, which is 21 x 3 x 3
>
> I want to use apply to sum on each 21x3 matrix, which is fine.
>
> Is there a way that I can do this in 1 step instead of a loop (3), please?

Don't know which direction you mean, I guess one of the following:

apply(x, c(1,2), sum)
apply(x, 3, sum)

Uwe Ligges


> thanks,
> Laura Holt
> mailto: holtlaura@(protected)
>
> ______________________________________________
> R-help@(protected)
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.