How to apply functions across columns?
On Wed, May 9, 2012 at 4:19 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
Good reproducible example ;-) Easiest is probably just: cbind(tencor, ThisRowMean = ?rowMeans(tencor[, 4:8]))
Actually, after frying my brain on tapply() and sapply() I found that just plain apply() does what I need: tencor$mean <- apply(tencor[4:8], 1, FUN=mean) This way I'm also not tied to just mean() as aggregator but can use any homemade function (this would have been my followup question had I followed your advice ;-) Thanks! robert