Re: [R] stringification magic in subset?

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Wed, 02 May 2007 08:35:08 -0700

ivo welch said the following on 5/2/2007 8:13 AM:
> dear R wizards:
>
> I am trying to replace subset() with my own version that first checks
> that each name in the select statement has a corresponding name in the
> data set. preferably, it would have the same syntax and semantics as
> subset() otherwise.
>
> alas, subset works in interesting ways:
>
> subset(d, select=col1)
>
> works just like
>
> subset(d, select="col1")
>
> somehow, subset manages to "stringify" its argument in such cases. Is
> it possible to duplicate the subset method one-for-one?
>
> a minor question---where do I find the source definition such as that
> of subset(), which is defined in
>

>> subset

> function (x, ...)
> UseMethod("subset")
> <environment: namespace:base>
>
> any help, as usual, appreciated.
>
> regards,
>
> /ivo
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.

Try:

methods("subset")

which will point you to "subset.data.frame". The latter code will answer your questions.

HTH, --sundar



R-help_at_stat.math.ethz.ch 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. Received on Wed 02 May 2007 - 15:44:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 May 2007 - 16:31:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.