[Rd] log2(quote(1:10)) evaluates the quoted 1:10, log() does not

William Dunlap wdunlap at tibco.com
Wed Mar 10 18:35:39 CET 2010


This is very minor, but shouldn't log2(quote(1:10))
throw an error,the same as log() and other math functions
do?  It looks like log2 and log10 evaluate a call object
instead of throwing a non-numeric-argument error.  They
do object to non-call language objects, like expressions.

  > log2(quote(1:10))
   [1] 0.000000 1.000000 1.584963 2.000000 2.321928 2.584963
   [7] 2.807355 3.000000 3.169925 3.321928
  > log(quote(1:10))
  Error in log(quote(1:10)) : Non-numeric argument to mathematical
function
  > sqrt(quote(1:10))
  Error in sqrt(quote(1:10)) :
    Non-numeric argument to mathematical function
  > quote(1:10) ^ 2
  Error in quote(1:10)^2 : non-numeric argument to binary operator
  > 2 ^ quote(1:10)
  Error in 2^quote(1:10) : non-numeric argument to binary operator

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 



More information about the R-devel mailing list