RE: [R] nargs() inside "[.myclass"

About this list Date view Thread view Subject view Author view Other groups

Subject: RE: [R] nargs() inside "[.myclass"
From: Vadim Kutsyy (vkutsyy@yahoo.com)
Date: Tue 27 Jun 2000 - 07:48:49 EST


Message-ID: <OFEGJMACADMFOKHCCFBJGELHCIAA.vkutsyy@yahoo.com>

> > "[.myclass"<-function(x,...)
> > {n<-nargs();print(n-1);m<-match.call();print(m)}
> > x[]
> [1] 1
> [.myclass(x = x, )
> > x[1]
> [1] 1
> [.myclass(x = x, 1)
> > x[1,2]
> [1] 2
> [.myclass(x = x, 1, 2)
>
> Doesn't look quite right... The problem sees to be that in the x[]
> case one passes two arguments of which one is missing (note that f(x)
> and f(x,) is not quite the same thing).

exactly, but if you don't pass anything at all, you can not even test if
something is missing, ie:

> "[.myclass"<-function(x,...) {n<-nargs();print(n-1);print(list(...))}
> x<-c(1,2,3)
> class(x)<-"myclass"
> x[1]
[1] 1
[[1]]
[1] 1

> x[]
[1] 1
Error in print(list(...)) : Argument is missing, with no default

As a result, I can not figure out way to see if it was pass as x[] or x[1].
It is possible to differentiate x[1,] vs x[1,2].

Any idea, how to get around it?

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:24 EST