[R] generate a series of fucntion
    Liaw, Andy 
    andy_liaw at merck.com
       
    Mon Jul 21 22:15:35 CEST 2003
    
    
  
Does this do sort of what you want?
> g1 <- list(function(x) log(x), function(x) log(x+1), function(x) x,
function(x) x^2)
> g1
[[1]]
function(x) log(x)
[[2]]
function(x) log(x+1)
[[3]]
function(x) x
[[4]]
function(x) x^2
> lapply(g1, function(g) {function(x,t) exp(-t[1]-t2*g(x)-t[3]*g(1+x))})
[[1]]
function(x,t) exp(-t[1]-t2*g(x)-t[3]*g(1+x))
<environment: 022BCBD8>
[[2]]
function(x,t) exp(-t[1]-t2*g(x)-t[3]*g(1+x))
<environment: 022BBD08>
[[3]]
function(x,t) exp(-t[1]-t2*g(x)-t[3]*g(1+x))
<environment: 022BBDCC>
[[4]]
function(x,t) exp(-t[1]-t2*g(x)-t[3]*g(1+x))
<environment: 022BBE90>
You did not say what g1 and g2 actually are, but I suppose the above should
give you enough hint.
Andy
> -----Original Message-----
> From: ximing wu [mailto:xiwu at uoguelph.ca] 
> Sent: Monday, July 21, 2003 3:54 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] generate a series of fucntion
> 
> 
> Hi there,
> 
> I want to generate a large amount of functions,
> 
> say f=function(x,t) exp(-t[1]-t[2]*g_1(x)-t[3]*g_2(1+x))
> 
> where g_1(x) and g_2(x) are from a long list of moments, such 
> as x, x^2, 
> log(x), log(1+x) .. and so on.
> 
> Any suggestions on how to do this efficiently?
> 
> thanks a lot.
> 
> x.w
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
> 
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, ...{{dropped}}
    
    
More information about the R-help
mailing list