[R] Search and convert string function
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sun Mar 6 05:46:10 CET 2005
On Sun, 6 Mar 2005, peng shen wrote:
> Hi all,
> I want to do this kind of function In R enviroment :
> For example :
> R <- 4
> testString <- "I love $R"
> then search this testString, when find "$R",replace "$R" to R ,and because
> the value of R is 4
> So the final string I want to get is "I love 4"
> How can I implement? Thanks advance
sub("$R", R, testString, fixed = TRUE)
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list