[R] Multidimensional Array: local averaging without knowing number of dimensions
schubert.seb at googlemail.com
Wed Apr 18 17:47:35 CEST 2012
I want to access and modify a multi dimensional array but without
knowing the exact number of dimensions.
Basically. I want something like that for every i (except boundaries of
field[i, ...] <- (field[i, ...] + field[i+1, ...] + field[i-1, ...])/3
In principle, ... should just represent the other dimension, for a 1
field[i] <- (field[i] + field[i+1] + field[i-1])/3
For a 2 dimensional field
field[i, ] <- (field[i, ] + field[i+1, ] + field[i-1, ])/3
For a 3 dimensional field
field[i,,] <- (field[i,,] + field[i+1,,] + field[i-1,,])/3
and so on.
Is there a way to formulate this without writing it for every number of
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 262 bytes
Desc: OpenPGP digital signature
More information about the R-help