Re: [R] functions and strings

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Wed 13 Sep 2006 - 07:54:22 GMT

Hi Dmitris

thanks for this but it's not quite right:

> f <- function(x){sin(x)+exp(x)}
> strng <- gsub("x", "xyz", deparse(body(f))[2])
> sub('^[[:space:]]+', '', strng)
[1] "sin(xyz) + exyzp(xyz)"

and I would want "sin(xyz) + exp(xyz)"

On 13 Sep 2006, at 08:45, Dimitris Rizopoulos wrote:

> strng <- gsub("x", "xyz", deparse(body(f))[2]) > sub('^[[:space:]]+', '', strng)

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

______________________________________________
R-help@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 Sep 13 21:05:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 13 Sep 2006 - 11:30: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.