methods(`|`) lists all functions?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

methods(`|`) lists all functions?

frederik-2
Dear R-Devel,

I was attempting an exercise in Hadley Wickam's book "Advanced R". The
exercise is to find the generic with the greatest number of methods.

I found that 'methods(`|`)' produces a list of length 2506, in R
3.3.1. Similar behavior is found in 3.4.0. It seems to include all
functions and methods. I imagine something is being passed to "grep"
without being escaped.

I hope I didn't miss something in the documentation, and that I'm good
to report this as a bug. I can send it to Bugzilla if that's better.

By the way, how do I produce such a list of functions (or variables)
in a "normal" way? I used 'ls("package:base")' for the exercise,
because I saw this call used somewhere as an example, but I couldn't
find that "package:" syntax documented under ls()... Also found this
confusing:

    > environmentName(globalenv())
    [1] "R_GlobalEnv"
    > ls("R_GlobalEnv")
    Error in as.environment(pos) :
      no item called "R_GlobalEnv" on the search list

So I'm not sure if "package:base" is naming an environment, or if
there are different ways to name environments and ls() is using one
form while environmentName is returning another ... It might be good
to add some clarifying examples under "?ls".

Thanks,

Frederick

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: methods(`|`) lists all functions?

Martin Morgan-3
On 12/08/2016 05:16 PM, [hidden email] wrote:
> Dear R-Devel,
>
> I was attempting an exercise in Hadley Wickam's book "Advanced R". The
> exercise is to find the generic with the greatest number of methods.
>
> I found that 'methods(`|`)' produces a list of length 2506, in R
> 3.3.1. Similar behavior is found in 3.4.0. It seems to include all
> functions and methods. I imagine something is being passed to "grep"
> without being escaped.

Exactly; I've fixed this in r71763 (R-devel).

Martin Morgan

>
> I hope I didn't miss something in the documentation, and that I'm good
> to report this as a bug. I can send it to Bugzilla if that's better.
>
> By the way, how do I produce such a list of functions (or variables)
> in a "normal" way? I used 'ls("package:base")' for the exercise,
> because I saw this call used somewhere as an example, but I couldn't
> find that "package:" syntax documented under ls()... Also found this
> confusing:
>
>     > environmentName(globalenv())
>     [1] "R_GlobalEnv"
>     > ls("R_GlobalEnv")
>     Error in as.environment(pos) :
>       no item called "R_GlobalEnv" on the search list
>
> So I'm not sure if "package:base" is naming an environment, or if
> there are different ways to name environments and ls() is using one
> form while environmentName is returning another ... It might be good
> to add some clarifying examples under "?ls".
>
> Thanks,
>
> Frederick
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


This email message may contain legally privileged and/or...{{dropped:2}}

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: methods(`|`) lists all functions?

frederik-2
On Thu, Dec 08, 2016 at 09:37:59PM -0500, Martin Morgan wrote:

> On 12/08/2016 05:16 PM, [hidden email] wrote:
> > Dear R-Devel,
> >
> > I was attempting an exercise in Hadley Wickam's book "Advanced R". The
> > exercise is to find the generic with the greatest number of methods.
> >
> > I found that 'methods(`|`)' produces a list of length 2506, in R
> > 3.3.1. Similar behavior is found in 3.4.0. It seems to include all
> > functions and methods. I imagine something is being passed to "grep"
> > without being escaped.
>
> Exactly; I've fixed this in r71763 (R-devel).
>
> Martin Morgan

Thank you.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel