Skip to content
Prev 314604 / 398502 Next

r code

On 01/04/2013 02:03 AM, catalin roibu wrote:
Hi catalin,
As your figure did not make it through to the list, I will have to do a 
bit of guessing. Your data seem to be 100 samples, each 0.01 M2 in area. 
These add up to 1 M2, so I'm not sure where the 10000 M2 comes from. The 
aggregations are not that difficult, simply specify sets of indices and 
use either the aggregate function you would like in a loop.
Assume that your data are in a data frame "mydata":

for(i in 1:100) cat("mean of 1:",i,mean(mydata[1:i,],na.rm=TRUE),"\n")
for(i in 1:100) {
  ind<-sample(1:100,2)
  cat("mean of",ind[1],"and",ind[2],mean(mydata[ind,],na.rm=TRUE]),"\n")
}

Jim