Skip to content
Back to formatted view

Raw Message

Message-ID: <55269066-9624-4810-8012-D0136CBD6320@comcast.net>
Date: 2011-11-26T16:24:05Z
From: David Winsemius
Subject: cumsum in 3d arrays
In-Reply-To: <1322317930681-4110470.post@n4.nabble.com>

On Nov 26, 2011, at 9:32 AM, zloncaric wrote:

> Hello!
>
> Is it posible to apply /cumsum()/ along the 3rd dimension of 3D array?
> Something like matrlab function - /cumsum (*A*,dim)/ which returns the
> cumulative sum of the elements along the dimension of *A* specified by
> scalar dim.
>

`apply` lets you chose which dimension gets selected.

Perhaps:

apply(mat, 3, cumsum)

(This is pretty basic stuff so you should probably be reading or at  
least skimming somewhat more thoroughly than you have so far the  
Introduction to R document and there is also the R for Matlab document  
by Bob Muenchen ... and a compendium of equivalencies by Hiebeler at: www.math.umaine.edu/~hiebeler/comp/matlabR.html 
  )

-- 

David Winsemius, MD
West Hartford, CT