On Sat, Nov 13, 2010 at 3:14 AM, Marius Hofert <m_hof...@web.de> wrote: > Dear expeRts, > > I would like to call a function f from a function g with or without an > argument. > I use missing() to check if the argument is given. If it is not given, can I > set > it to anything such that the following function call (to f) behaves as if the > argument > isn't given? It's probably best described by a minimal example (see below). > > The reason why I want to do this is, that I do not have to distinguish > between the > cases when the argument is given or not. By setting it to something (what?) > in the > latter case, I can use the same code in the subsequent part of the function. >
You can pass missing values: f <- function(x) g(x) g <- function(x) missing(x) f(3) # FALSE f() # TRUE -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.