on 01/20/2009 05:26 PM Czerminski, Ryszard wrote: > Passing extra arguments to FUN=mean or median in apply > seems fine, but when FUN=min warnings are generated? > See below. > > Any ideas why? > > Best regards, > Ryszard > > Ryszard Czerminski > AstraZeneca Pharmaceuticals LP > >> m > [,1] [,2] > [1,] 1 2 > [2,] 3 NA > [3,] NA NA >> apply(m, 1, median, na.rm=T) > [1] 1.5 3.0 NA >> apply(m, 1, mean, na.rm=T) > [1] 1.5 3.0 NaN >> apply(m, 1, min, na.rm=T) > [1] 1 3 Inf > Warning message: > In FUN(newX[, i], ...) : no non-missing arguments to min; returning Inf
Not a problem with min(), it is an issue with the last row being an empty set after removing the 2 NAs since na.rm = TRUE. > min(NA, NA, na.rm = TRUE) [1] Inf Warning message: In min(NA, NA, na.rm = TRUE) : no non-missing arguments to min; returning Inf You are effectively doing: > min(numeric(0)) [1] Inf Warning message: In min(logical(0)) : no non-missing arguments to min; returning Inf See: http://wiki.r-project.org/rwiki/doku.php?id=tips:surprises:emptysetfuncs for more information on empty sets. HTH, Marc Schwartz ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

