[R] select one function from two of them in another function

2009-08-27 Thread SH.Chou
Hi all, I have two functions called test1() and test2(). Now how do I select one of them in test3()?? Say test3<-function(func="test1"){ if (func=="test1"){ now.func<-test1() } else now.func<-test2() } I know this function I wrote does not right. Do an

Re: [R] select one function from two of them in another function

2009-08-27 Thread jim holtman
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

Re: [R] select one function from two of them in another function

2009-08-27 Thread Bert Gunter
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