Skip to content

nargs() inside "[.myclass"

1 message · David James

#
[rgentlem at stat.auckland.ac.nz]
I'm not sure this is a bug, but is is consistent with S. 

If we invoke the function ourselves we get the same behaviour:

# R 1.0.0
function(x, ...) print(nargs()-1)
[1] 0
[1] 1
[1] 1
[1] 2

Clearly the generic function will create a call with the "x"
argument plus "..." -- this means that

  x[]    <------>  "[.myclass"(x,)    two args, 2nd arg missing
  x[1]   <------>  "[.myclass"(x,1)   two args, no missing
  x[1,2] <------>  "[.myclass"(x,1,2) three args, no missing

The question now becomes whether R/S should dispatch "x.myclass"(x)
for x[] or "x.myclass(x,) as it's currently done.  

BTW see p.476 in Appendix A of Chambers and Hastie (ed.) "Statistical 
Models in S" for an example just like the problem Vadim is trying to
solve.
David A James                        Phone: (908) 582-3082
Bell Labs, Lucent Technologies       Fax:   (908) 582-3340
600 Mountain Ave                     Email: dj at bell-labs.com
Murray Hill, NJ 07974

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._