[R] How to make a function aware of its own call arguments

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Thu Mar 24 13:47:17 CET 2016

Don't provide a default value for c in the parameter list.  Then you can use the missing() function to make decisions, including whether to generate a default value for c or not.
Sent from my phone. Please excuse my brevity.

On March 24, 2016 5:11:43 AM PDT, sbihorel <Sebastien.Bihorel at cognigencorp.com> wrote:
>Please consider the following functions:
>myf1 <- function(x,fun){
>   if (is.null(fun)){
>     x
>   } else {
>     do.call(fun, list(x))
>   }
>myf2 <- function(a=1, b=2, fun=NULL, c=myfun1(b,fun)){
>   if (myf1(b,fun)>0 & <c was not provided in function call>){
>     c <- b
>   }
>   print(list(a,b,c))
>I need to replace "<c was not provided in function call>" by some code 
>that would make myf2 aware of it own calls and of the fact that the c 
>argument was provided or not in the function calls.
>Thanks for your help
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list