An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130103/424bc86e/attachment-0001.pl>
r code
2 messages · catalin roibu, Jim Lemon
On 01/04/2013 02:03 AM, catalin roibu wrote:
I have a problem. My data is now in this form: plot area d 1 0.01 34.6 ................... 100 0.01 15.7 First, I want to aggregate plots start from a plot in the center of sample (10 plots x 10 plots). I want to aggregate after the model plot1 in the center of area (0,01 m2), after increasing plot area with the near plots until the entire area (10000 m2). For a good explication I will attach a figure. Second, I want to aggregate plots starting to 1, 1, with 2 , 1 with 2 with 3 .....1 with 2 with 3........with 99 with 100. Third> I want to aggregate the values but choose random>Ex. 75, 9 with 83,......etc Thank you very much!
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