Hi,

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
course):

field[i, ...] <- (field[i, ...] + field[i+1, ...] + field[i-1, ...])/3

In principle, ... should just represent the other dimension, for a 1
dimensional field:

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
dimension?

Cheers
Sebastian

Attachment: signature.asc
Description: OpenPGP digital signature

______________________________________________
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