[R] Completion for custom "$" operator?

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Aug 7 09:38:06 CEST 2009


On 8/7/09, Romain Francois <romain.francois at dbmail.com> wrote:
> On 08/04/2009 10:02 PM, Deepayan Sarkar wrote:
>
> > On Tue, Aug 4, 2009 at 11:37 AM, Vitalie S.<vitosmail at rambler.ru>  wrote:
> >
> > > Dear UseRs,
> > >
> > > I declared a `$` method for a S4 class. Can I have ab automatic
> completion
> > > for this operator in R? Lists and environment objects provide this
> feature
> > > by default, but my object is an extension of "function" class which does
> not
> > > have subseting defined. How to be?
> > >
> >
> > Completion should be automatic if you define names() to return the valid
> names.
> >
> > -Deepayan
> >
>
>  Hi,
>
>  Shouldn't this be delegated to a custom method. ie :
>
>  complete <- function( x, ... ){
>         UseMethod( "complete" )
>  }
>  complete.default <- function( x, ... ){
>         names( x )
>  }
>
>  or maybe the equivalent S4 incantation.
>
>  This would separate the completion from the names, and therefore give more
> flexibility to class writers.

Ideally yes (although "complete" doesn't seem the best choice; this is
only for $ completion). It's an easy enough change, and I'll be happy
to make it if there's interest (and a use case where names() has good
reason to be different).

-Deepayan




More information about the R-help mailing list