[R] Remove " from a string
Greg Snow
Greg.Snow at intermountainmail.org
Fri Dec 8 17:08:11 CET 2006
The best approach is probably to load all of your functions into a list:
> myfunctions <- list()
> myfunctions[[1]] <- NameOfFunction1
> myfunctions[[2]] <- NameOfFunction2
...
Or
> myfunctions <- list()
> for (i in 1:98){
+ myfunctions[[i]] <- get( paste('NameOfFunction',i,sep='') )
+ }
>
Then you can run the function like:
> myfunctions[[Number]](data, ...)
You could use 'get' directly, but the list of functions is probably
cleaner.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Katharina
Vedovelli
Sent: Friday, December 08, 2006 6:57 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Remove " from a string
Hi all!
I have lots of functions called in the following pattern
'NameOfFunctionNumber' where the name always stays the same and the
number varies from 1 to 98.
Another function which I run in advance returns the number of the
function which has to be called next.
Now I want to combine 'NameOfFunction' with the 'Number' returned so
that i can call the desired function.
I do this by:
x<-c("NameOfFunction",Number)
z<-paste(x,collapse="")
z
which returns
"NameOfFunctionNumber"
My Problem is that R doesn't recognise this as the name of my function
because of the " at the beginning and the end.
Is there a way of getting rid of those? Or does anybody know another way
of solving this problem?
Thanks a lot for your help!
Cheers,
Katharina
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
More information about the R-help
mailing list