Skip to content
Prev 101027 / 398500 Next

do.call with Vectorial Argument

On 10/3/2006 10:46 AM, Lorenzo Isella wrote:
That's probably not the best choice.  You might want to think about 
writing a wrapper for the function instead; you'll end up with easier 
code to read and debug.
Take a look at what c(list(t=newtime),mypar) gives you:  it's a list of 
length 2.  You want a list of length 4.

To get that, just use mypar <- list(q, lam1, lam2).

Or better still, write a wrapper function, e.g.

better_sigma <- function() {
   sigma_pos_old(t, q, lam1, lam2)
}

Remember that better_sigma will look up the variables t, q, lam1, and 
lam2 in whatever environment it was defined in, so if you have a 
function that modifies local copies of those variables and then calls 
better_sigma, you should define better_sigma within that function.

Duncan Murdoch