[R] Meaning of .local and the special token ..1 returned from match.call

Niels Richard Hansen Niels.R.Hansen at math.ku.dk
Thu Feb 19 10:29:47 CET 2009


I am writing a version of the subset function for
a new class. I don't understand the behavior of match.call
in this particular case, and I didn't seem to be able to
find much help in the language definition or the email archive.
Here follows a minimal example:

setClass("myClass",
          representation(id = "factor")
          )

setMethod("subset","myClass",
           function(x,subset,...) match.call()
           )

tmp <- new("myClass",id=factor(1:10))
subset(x=tmp,subset=id >5)

which gives me

.local(x = x, subset = ..1)

I want to call a further subset function, subset.data.frame, say,
using the unevaluated expression "id > 5", but in this setup I
don't understand how I should proceed. I can't find any explanation of 
.local and what the ..1 means, except that ..1 is a "special token". A 
small modification of the method as

setMethod("subset","myClass",
           function(x,...) match.call()
           )

where I exclude explicitly mentioning the subset argument
gives, however, what I expected:

subset(x = tmp, subset = id > 5)

This might be OK, and I am able to get everything to work without
having an explicit subset argument in the class method -- by passing
the ... -- but I think it would be nice to have the subset argument like 
in the S3 version of subset.data.frame.

It seems that the issue is related to the fact that the generic
subset method has the arguments (x,...). Is there a way to get around 
this so that my method can have explicit additional arguments like the
subset-argument?

Thanks for any help, Niels


-- 
Niels Richard Hansen
Associate Professor
Department of Mathematical Sciences
University of Copenhagen
Universitetsparken 5
2100 Copenhagen Ø
Denmark
+45 353 20783




More information about the R-help mailing list