[R] Transforming a string into a command
Petr PIKAL
petr.pikal at precheza.cz
Tue Nov 29 11:01:25 CET 2011
Hi
>
> Did my reply get orphaned or are you trying to help me realize that
asking
> why something does not work is not a straightforward question? I'll try
to
> cover both bases.
>
> I'll focus just on the first case that I don't understand. Suppose we
have
> s<- "ln(a+b)"
> a<-1
> b<-2
> eval(parse(text=s))
> Error in eval(expr, envir, enclos) : could not find function "ln"
What is function ln supposed to do and to what package it belongs. I get
> ?ln
No documentation for ‘ln’ in specified packages and libraries:
you could try ‘??ln’
but it does not mean that ln is not used elsewhere.
Regards
Petr
>
> Perhaps it's because I don't understand eval well (any good references
for
> reading up on eval, parse, substitute, etc.?). But I expected it to
produce
> the same as the following line:
> eval(parse(text="ln(a+b)"))
>
> Xu
>
>
> David Winsemius wrote
> >
> > On Nov 29, 2011, at 2:00 AM, Xu Wang wrote:
> >
> >> Why don't the following two commands work?
> >>
> >> eval(parse(text=s))
> >> eval(as.expression(s))
> >>
> >
> > Can you think of anything else we might need to know in order to
> > answer that question?
> >
> > --
> >
> > David Winsemius, MD
> > West Hartford, CT
> >
> > ______________________________________________
> > R-help@ 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.
> >
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Transforming-
> a-string-into-a-command-tp4112183p4118294.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.
More information about the R-help
mailing list