Skip to content
Prev 34700 / 63424 Next

sapply improvements

If this new argument gets used much it may give a
push towards getting functions to always return the
same type of output.  E.g., range(integer(0)) returns
a numeric while range(integer(1)) an integer, resulting
in:
   > z<-split(1:10, cut(log(1:10),breaks=0:4,include.lowest=TRUE))
   > # z[[4]] is integer(0)
   > sapply(z,range,FUN.VALUE=integer(2))
   Error in sapply(z, range, FUN.VALUE = integer(2)) : 
     FUN values must be of type 'integer'
   In addition: Warning messages:
   1: In min(x) : no non-missing arguments to min; returning Inf
   2: In max(x) : no non-missing arguments to max; returning -Inf