On 9 January 2012 08:53, Phil Wiles <philip.wi...@gmail.com> wrote:
> I have a multidimensional array - in this case with 4 dimensions of x,y,z
> and time.  I'd like to take the time derivative of this matrix, i.e.
> perform the diff operator along dimension number 4.

"apply" can do that, but you may need to reorder the dimensions of the result.

  a <- array(1:81,dim=c(3,3,3,3))
  b <- apply(a, 1:3, diff)
  b <- aperm(b,c(2:4,1))
  dim(b)

-- Vincent

______________________________________________
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