the man page for relational operators (see, e.g., ?'<') says:

"
Binary operators which allow the comparison of values in atomic vectors.

Arguments:

    x, y: atomic vectors, symbols, calls, or other objects for which
          methods have been written.
"

it is somewhat surprizing that the following works:

    '<'(1)
    # logical(0)

    '<'()
    # logical(0)

    '<'(1,2,3)
    # TRUE

what does 'binary' mean here, precisely?  in the first two examples, one
might suspect that '<' treats the missing arguments as missing values,
but this would not be coherent with what the man page says:

"
 Missing values ('NA') and 'NaN' values are regarded as
     non-comparable even to themselves, so comparisons involving them
     will always result in 'NA'.
"

i can't find the above explained in the documentation.  typing `<` shows
that it is a

    function(e1, e2) .Primitive("<")

how come can/should it work with no complaint on input that does not
consist of exactly 2 arguments?
in scheme (which is claimed to have been an inspiration for r), < works
on an arbitrary number of arguments:

    (<)
    ;; #t
    (< 1)
    ;; #t
    (< 1 2 3)
    ;; #t
    (< 1 2 0)
    ;; #f

but there < is an arity-dispatched procedure, not a binary one, and it
produces sensible output for any number of arguments (arguably for n=0, 1).

vQ

______________________________________________
R-help@r-project.org 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.

Reply via email to