Skip to content
Prev 305654 / 398506 Next

count NAs per week

On Mon, Sep 17, 2012 at 11:03 AM, Tagmarie <Ramgad82 at gmx.net> wrote:
Thanks for the reproducible example: there are many ways to do this
(aggregate, tapply, ave, etc.) but they are all based on the paradigm
of: break up your data by "Week" --> apply the function "function(x)
sum(is.na(x))" --> recombine. (See, inter alia, the JSS paper on the
plyr package) I'm not at a computer with R right now so this is a
little untested, but one way might be:

with(dattrial, tapply(a, Week, function(x) sum(is.na(x))))

Cheers,
Michael