Re: [R] functions and strings

From: Romain Francois <rfrancois_at_mango-solutions.com>
Date: Wed 13 Sep 2006 - 07:44:00 GMT

Robin Hankin wrote:
> Hi
>
> If
>
> string <- "xyz"
> f <- function(x){1 + sin(cos(x)) + exp(x^2)}
>
> How do I manipulate "string" and f() to give the string
>
> "1 + sin(cos(xyz)) + exp(xyz^2)"
>
> ?
>
Hi,

Here what i'll do :

f <- function(x){
  sprintf("1 + sin(cos(%s)) + exp(%s^2)", x, x) }

Cheers,

Romai

> --
> 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.
>
>



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 18:50:36 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 - 09: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.