Binning average in R?

Here is another way to do it: set. Seed(5) x = matrix(runif(1000), ncol = 10) nr = nrow(x) gr = rep(1:floor(nr/10), each = 10) aggregate(x ~ gr, FUN=mean),-1 which results in NA NA.1 NA.2 NA.3 NA.4 NA.5 NA.6 NA.7 1 0.5295264 0.5957229 0.4502069 0.5168083 0.3398190 0.4075922 0.6059122 0.5127865 2 0.4778341 0.3967321 0.4069635 0.4514742 0.6172677 0.2486085 0.6340686 0.4052600 3 0.5168132 0.5117207 0.5202261 0.5068593 0.5218041 0.4925462 0.5169584 0.4919296 4 0.3299557 0.3314723 0.4503393 0.3965103 0.6166598 0.5525628 0.4943880 0.6048207 5 0.6145423 0.5853235 0.4822182 0.3377771 0.3540784 0.5974846 0.5202577 0.5769518 6 0.5009249 0.5203701 0.3940540 0.4237508 0.3199265 0.4817713 0.4655320 0.6124400 7 0.7335082 0.5856578 0.3929621 0.6403662 0.5347719 0.5658542 0.4226456 0.7196593 8 0.4976663 0.5205538 0.4529273 0.4757352 0.6980300 0.5694570 0.4384924 0.5481236 9 0.5275932 0.5014861 0.5363340 0.5664576 0.5006055 0.5611069 0.3803889 0.4680865 10 0.4560031 0.5527328 0.4419076 0.6893043 0.5161281 0.5895931 0.3965911 0.3842419 NA.8 NA.9 1 0.3711607 0.5541607 2 0.4379255 0.4159131 3 0.5048523 0.5884052 4 0.4642687 0.4572388 5 0.6054209 0.5174784 6 0.4659952 0.5332438 7 0.4568273 0.3943798 8 0.6978356 0.5087778 9 0.4897584 0.4710949 10 0.6310546 0.4775762.

T( sapply(1:(NROW(A)/10), function(x) colMeans(A x:(x+9), ) ) ) You need the transpose operation to re-orient the result. One often needs to do so after an 'apply' operation.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send