Try apply(A,2:3,sum)
--- Saurav Pathak <[EMAIL PROTECTED]> wrote: > Hi, > > I cannot seem to figure out how to sum over an index > of a array. > For example, let A be a 3 dimensional array. I want > to, say, find > the sum over the first dimension. That is > > S_jk = Sum_i A_ijk > > where now S is a 2-dim matrix. I dont want to use a > loop. > > Thanks, > -- > saurav > > ______________________________________________ > 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. > ______________________________________________ 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.