Skip to content
Prev 277491 / 398506 Next

using tapply() with the quantile function?

David:

You need to re-read ?tapply _carefully_.? Note that:

FUN   the function to be applied, or NULL. In the case of functions
like +, %*%, etc., the function name must be backquoted or quoted.

Now note that in tapply(whatever, byfactor,  mean),   "mean" _is_ a function.
However in tapply (whatever,byfactor,  quantile(something, .9) )
"quantile(something, .9)" is not a function -- it's a function _call_
.

So correct syntax would be:

tapply(whatever, byfactor, quantile, probs=.9)  ## probs is a "..."  argument

Alternatively, using anonymous functions, you could do:

tapply(whatever, byfactor, function(x)quantile(x, probs=.9))

where unnamed ("anonymous") function has been written in place for the
FUN argument of tapply.

Cheers,
Bert

On Tue, Nov 15, 2011 at 11:54 AM, Kulpanowski, David
<DKulpanowski at leegov.com> wrote:
--

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm