Skip to content
Prev 30333 / 398506 Next

naming an operation inside a function

I don't understand what it would mean to "name" a specific
operation inside a function, so that you could "call it"
later on.

It's perfectly possible to define and use one function
inside the scope of another.  E.g.

conditional.plot <- function(cond, ...)
   {  if (cond[1]) plot(...) else hist(...)  }

(Poorly designed example, since it depends on having
named arguments "x" or "x" and "y" in ... for correct
execution of the plotting commands, and, in its present
form, doesn't use that as part of the condition ... but.)

Ah, with this example I can see that one reason why you
might want to do this is if you want the side effects of
function.a or function.b, such as a plot, rather than
their return values.

-  tom blackwell  -  u michigan medical school  -  ann arbor  -
On Mon, 7 Apr 2003, [iso-8859-1] Dave Caccace wrote: