SH.Chou
Cc: r-help@r-project.org
Subject: Re: [R] select one function from two of them in another function
Is this what you want -- this returns a function that you can then call:
test1 <- function() 1
test2 <- function() 2
> test3 <- function(func='test1'){ # return the
Is this what you want -- this returns a function that you can then call:
> test1 <- function() 1
> test2 <- function() 2
> test3 <- function(func='test1'){ # return the function to call
+ if (func == 'test1') return(test1)
+ return(test2)
+ }
>
> # test it
> test3()() # default -- notice
2 matches
Mail list logo