Access function as text from package by name

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

Access function as text from package by name

Sigbert Klinke
Hi,

I want to have a function, e.g. graphics::box, as text.
Currently I'am using

deparse(eval(parse(text='graphics::box')))

It is important that '::' and ':::' can be used in the name.

Is there a simpler way?

Thanks

Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Access function as text from package by name

Rui Barradas
Hello,

Maybe

capture.output(graphics::box)


Hope this helps,

Rui Barradas

Às 11:30 de 27/09/2018, Sigbert Klinke escreveu:

> Hi,
>
> I want to have a function, e.g. graphics::box, as text.
> Currently I'am using
>
> deparse(eval(parse(text='graphics::box')))
>
> It is important that '::' and ':::' can be used in the name.
>
> Is there a simpler way?
>
> Thanks
>
> Sigbert
>
>
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Access function as text from package by name

R help mailing list-2
Or

  sink('stuff.txt') ; graphics::box ; sink()

to have it in a text file.

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 9/27/18, 4:55 AM, "R-help on behalf of Rui Barradas" <[hidden email] on behalf of [hidden email]> wrote:

    Hello,
   
    Maybe
   
    capture.output(graphics::box)
   
   
    Hope this helps,
   
    Rui Barradas
   
    Às 11:30 de 27/09/2018, Sigbert Klinke escreveu:
    > Hi,
    >
    > I want to have a function, e.g. graphics::box, as text.
    > Currently I'am using
    >
    > deparse(eval(parse(text='graphics::box')))
    >
    > It is important that '::' and ':::' can be used in the name.
    >
    > Is there a simpler way?
    >
    > Thanks
    >
    > Sigbert
    >
    >
    >
    > ______________________________________________
    > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
    > 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.
    >
   
    ______________________________________________
    [hidden email] mailing list -- To UNSUBSCRIBE and more, see
    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.
   

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Access function as text from package by name

Henrik Bengtsson-5
In reply to this post by Sigbert Klinke
deparse(graphics::box)

/Henrik
On Thu, Sep 27, 2018 at 3:30 AM Sigbert Klinke
<[hidden email]> wrote:

>
> Hi,
>
> I want to have a function, e.g. graphics::box, as text.
> Currently I'am using
>
> deparse(eval(parse(text='graphics::box')))
>
> It is important that '::' and ':::' can be used in the name.
>
> Is there a simpler way?
>
> Thanks
>
> Sigbert
>
> --
> https://hu.berlin/sk
> https://hu.berlin/mmstat3
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Access function as text from package by name

Sigbert Klinke
In reply to this post by Sigbert Klinke
Hi,

I guess I was not clear enough: the name of the function is stored as
string. Solutions which use the object directly do not help unfortunately.

Thanks Sigbert

Am 27.09.2018 um 12:30 schrieb Sigbert Klinke:

> Hi,
>
> I want to have a function, e.g. graphics::box, as text.
> Currently I'am using
>
> deparse(eval(parse(text='graphics::box')))
>
> It is important that '::' and ':::' can be used in the name.
>
> Is there a simpler way?
>
> Thanks
>
> Sigbert
>
>
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

--
https://hu.berlin/sk
https://hu.berlin/mmstat3


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Access function as text from package by name

Bert Gunter-2
Do you mean:
?get



On Thu, Sep 27, 2018, 11:44 PM Sigbert Klinke <[hidden email]>
wrote:

> Hi,
>
> I guess I was not clear enough: the name of the function is stored as
> string. Solutions which use the object directly do not help unfortunately.
>
> Thanks Sigbert
>
> Am 27.09.2018 um 12:30 schrieb Sigbert Klinke:
> > Hi,
> >
> > I want to have a function, e.g. graphics::box, as text.
> > Currently I'am using
> >
> > deparse(eval(parse(text='graphics::box')))
> >
> > It is important that '::' and ':::' can be used in the name.
> >
> > Is there a simpler way?
> >
> > Thanks
> >
> > Sigbert
> >
> >
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > 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.
> >
>
>
> --
> https://hu.berlin/sk
> https://hu.berlin/mmstat3
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Access function as text from package by name

Deepayan Sarkar
On Fri, Sep 28, 2018 at 2:16 PM Bert Gunter <[hidden email]> wrote:
>
> Do you mean:
> ?get

Doesn't work with :: etc:

> get("graphics::box")
Error in get("graphics::box") : object 'graphics::box' not found

I think parse()+eval() is pretty much unavoidable. After that, it's a
choice between deparse() and print()+capture.output().

-Deepayan


> On Thu, Sep 27, 2018, 11:44 PM Sigbert Klinke <[hidden email]>
> wrote:
>
> > Hi,
> >
> > I guess I was not clear enough: the name of the function is stored as
> > string. Solutions which use the object directly do not help unfortunately.
> >
> > Thanks Sigbert
> >
> > Am 27.09.2018 um 12:30 schrieb Sigbert Klinke:
> > > Hi,
> > >
> > > I want to have a function, e.g. graphics::box, as text.
> > > Currently I'am using
> > >
> > > deparse(eval(parse(text='graphics::box')))
> > >
> > > It is important that '::' and ':::' can be used in the name.
> > >
> > > Is there a simpler way?
> > >
> > > Thanks
> > >
> > > Sigbert
> > >
> > >
> > >
> > > ______________________________________________
> > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > > 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.
> > >
> >
> >
> > --
> > https://hu.berlin/sk
> > https://hu.berlin/mmstat3
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > 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.
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.