[Rd] choose incorrect for fractional and some negative integer values (PR#10766)
jerry.lewis at biogenidec.com
jerry.lewis at biogenidec.com
Wed Mar 19 14:25:33 CET 2008
choose(-5,-7) uses integer arguments (as specified in Help) and returns a
numeric value that is incorrect. Either the function or the documentation
should be fixed. If the function is not fixed, a warning or an error
would be helpful.
The fact that choose(n,k) usually returns choose(n,round(k,0)) is not
obvious from either the output or the documentation. I suggest issuing a
warning when k is not an integer; a user might easily expect that choose
would coerce both arguments to integers, but only coercing k to an integer
is unusual and potentially misleading.
The fact that choose(n,k) always rounds .5 up in k (contrary to the round
function documentation) is nowhere documented.
Help for coerce would lead a reader to expect k to be truncated toward
zero (as.integer), instead of rounding it.
Jerry
[[alternative HTML version deleted]]
More information about the R-devel
mailing list