[R] How to force aggregate to exclude NA ?
hadley wickham
h.wickham at gmail.com
Sun Dec 7 19:00:50 CET 2008
On Sun, Dec 7, 2008 at 10:10 AM, Daren Tan <daren76 at hotmail.com> wrote:
>
> How to use the na.rm function outside aggregate ? I tried
>
> na.rm <- function(f) {
> function(x, ...) f(x[!is.na(x)], ...)
> }
>
>
>>na.rm(sum(c(NA,1,2)))
>
> function(x, ...) f(x[!is.na(x)], ...)
>
>
>> na.rm(sum, c(NA,1,2))
> Error in na.rm(sum, c(NA, 1, 2)) : unused argument(s) (c(NA, 1, 2))
na.rm(sum)(c(NA, 1, 2))
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list