Skip to content
Back to formatted view

Raw Message

Message-ID: <56F3D97F.1080607@cognigencorp.com>
Date: 2016-03-24T12:11:43Z
From: Sebastien Bihorel
Subject: How to make a function aware of its own call arguments

Hi,

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))
}

myf2(a=2,b=3,fun=exp)
myf2(a=2,b=3,fun=exp,c=4)

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

Sebastien