Re: [R] Function to Define a Function

2010-08-10 Thread S Ellison
Neat. But why assign the functions to separate variables at all? mdlChooser <- function(type=c("one","two")) { type <- match.arg(type) m <- switch(type, one=function(x,N0,r) N0*exp(x*r) , two=function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) ) m } also works without appearing to

Re: [R] Function to Define a Function

2010-08-10 Thread Martin Maechler
> Gabor Grothendieck > on Mon, 9 Aug 2010 23:20:18 -0400 writes: > On Mon, Aug 9, 2010 at 9:31 PM, Derek Ogle wrote: >> I am trying to define a general R function that has a >> function as the output that depends on the user's input >> arguments (this may make more s

Re: [R] Function to Define a Function

2010-08-10 Thread Thomas Lumley
On Mon, 9 Aug 2010, Derek Ogle wrote: I am trying to define a general R function that has a function as the output that depends on the user's input arguments (this may make more sense by looking at the toy example below). My real use for this type of code is to allow a user to choose from ma

Re: [R] Function to Define a Function

2010-08-10 Thread Greg Snow
o: R (r-help@R-project.org) > Subject: [R] Function to Define a Function > > I am trying to define a general R function that has a function as the > output that depends on the user's input arguments (this may make more > sense by looking at the toy example below). My real use f

Re: [R] Function to Define a Function

2010-08-10 Thread Derek Ogle
Gabor ... that worked perfectly. Thank you. > -Original Message- > From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] > Sent: Monday, August 09, 2010 10:20 PM > To: Derek Ogle > Cc: R (r-help@R-project.org) > Subject: Re: [R] Function to Define a Function >

Re: [R] Function to Define a Function

2010-08-09 Thread Gabor Grothendieck
On Mon, Aug 9, 2010 at 9:31 PM, Derek Ogle wrote: > I am trying to define a general R function that has a function as the output > that depends on the user's input arguments (this may make more sense by > looking at the toy example below).  My real use for this type of code is to > allow a user

[R] Function to Define a Function

2010-08-09 Thread Derek Ogle
I am trying to define a general R function that has a function as the output that depends on the user's input arguments (this may make more sense by looking at the toy example below). My real use for this type of code is to allow a user to choose from many parameterizations of the same general