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
> 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
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
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
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
>
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
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
7 matches
Mail list logo