Skip to content
Prev 163986 / 398503 Next

How to force aggregate to exclude NA ?

Actually the second aggregate and second rowsum don't need the na.rm = TRUE
so we only need:

aggregate(!is.na(m[, -(1:2)]), m[1], sum)
rowsum(0+!is.na(m[, -(1:2)]), m[,1])

You might also want to look at summaryBy in the doBy package.

On Sun, Dec 7, 2008 at 7:43 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote: