On 02/11/11 13:43, Ernest Adrogué wrote:
<SNIP>
Sorry for not stating my problem in a more clear way. What I want is,
given an array of n dimensions, overwrite it by iteratating over its
"outermost" dimension... OK, in the previous example, I would like
to do
x<- array(NA, c(2,2,2))
for (i in 1:2) {
x[,,i]<- 0
}
As you can see, the index I used in the loop only works in the case of
three-dimensional arrays, if x was two dimensional I would have had to
write
for (i in 1:2) {
x[,i]<- 0
}
<SNIP>
Uhhhh, how does this differ from just setting *all* entries of x
equal to 0, e.g.:
x[] <- 0
???
cheers,
Rolf Turner
______________________________________________
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.