Thanks a lot for your help

marco

2011/5/27 Thomas Lumley <tlum...@uw.edu>

> On Fri, May 27, 2011 at 10:06 AM, marco milella <vru...@gmail.com> wrote:
> > Hi to everybody
> > I have an array with dimensions 2,4,3,3.
> > Wanting to sum the matrices in the first two dimensions, I'm trying to
> use
> > the "apply" function, but with no results. Have to say I'm quite new with
> R
> > syntax.
>
> Tell apply() which dimensions you want to keep, in this case 3 and 4
>
> R> m<-array(1, dim=c(2,4,3,3))
> R> apply(m,3:4,sum)
>     [,1] [,2] [,3]
> [1,]    8    8    8
> [2,]    8    8    8
> [3,]    8    8    8
>
>    -thomas
>
> --
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
>



-- 
Dr. Marco Milella

Anthropologisches Institut & Museum
Universität Zürich-Irchel
Winterthurerstrasse 190
8057 Zürich
Schweiz
e-mail: marco.mile...@aim.uzh.ch
phone: +41-44-635-5428
fax:   +41-44-635-6886

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to