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 anyone
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 the
-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 function to call
+ if (func == 'test1') return(test1
3 matches
Mail list logo