Greetings,
Dumb question of the day?....
I have a fitting routine with an string argument "method" which calls MS
with a function whose name I can construct using the string argument
"method" using paste (func<-paste("something",method,sep=".") I then
want to use func as a function in the formula argument in the ms call
(fit<-ms(func(things)...))
I think I need the correct incantation of substitute, deparse,
expression and eval, but despite a lot of playing can't get it to work.
I can do it if I put the function name as the argument in the function
call, with no need for any messing about.
Any suggestions? I bet it's simple but the documentation is rather
obscure! (My copy of V&R is on order!)
Steve.
===============================================
some pseudo S code:
-------------------
#what I want is this
my.function<-function( method, other.things)
{
#build function name
func<-paste("root",method,sep=".")
#call MS with function
msfit<-ms(~func(various.things),more.things)
}
#define the real functions
root.a<-function(things) {...}
root.b<-function(things) {...}
#call my function to use the various fitting routines...
my.function(a,other.things)
my.function(b,other.things)
-----------------
#this works, but is not as flexible for my application
my.function<-function(func, other.things)
{
msfit<-ms(~func(various.things),more.things)
}
define the real functions
root.a<-function(things) {...}
root.b<-function(things) {...}
#call my function to use the various fitting routines...
my.function(root.a,other.things)
my.function(root.b,other.things)
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|