Skip to content
Prev 359755 / 398503 Next

apply mean function to a subset of data

Your toy code does not reproduce what you describe: mean(toy$diam[1:nsel[i]]) both times selects from elements of group 1. YOu probably want to subset like toy$diam[toy$group == i]. Also, if there is any real inefficiency here, it is _not_ because you are executing a for-loop for two iterations. What makes you think you have an efficiency problem?


B.
On Apr 2, 2016, at 2:46 PM, Pedro Mardones <mardones.p at gmail.com> wrote: