Re: [R] R - Array data loop selection

2012-02-05 Thread dengyu19901102
Don't worry, i have figured it out. I forgot the most basic method by adding another increasing loop counter. k=0 for (yr in 1982:2010) { temp <- ssta_sst[,,year_sst==yr & (month_sst>=6 & month_sst<=8)] k=k+1 for (i in 1:360) { for (j in 1:180) {

Re: [R] R - Array data loop selection

2012-02-05 Thread dengyu19901102
the structure of ssta_sst can be seen below. > dim(ssta_sst) [1] 360 180 362 Also, the debugging for temp is right. The problem for that code is the temp doesn't pass down as it suppose to be, it only gives the last value in 2010. > for (yr in 1982:2010) { + temp <- ssta_sst[,,year_sst==yr & (mo

[R] R - Array data loop selection

2012-02-04 Thread dengyu19901102
i want to select June, July and August data from the 3D array (`ssta_sst`, 360*180*362). the loop works but the output of ssta_winter has the identical values for `ssta_winter[,,i]`.seen below. I have set it up as an array of (360,180,29). I think the problem is the variable `temp`, i want to def