Skip to content

Odd and Even

4 messages · Adaikalavan Ramasamy, Dave Caccace, Thomas W Blackwell +1 more

#
Or if you are very lazy there is is.odd() and is.even() in library sma.

-----Original Message-----
From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de] 
Sent: Sunday, April 06, 2003 8:36 PM
To: Dave Caccace
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Odd and Even
Dave Caccace wrote:
if(p %% 2) "odd" else "even"

Uwe Ligges

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
#
Thank you for you previous help :)

I now need ot know how i can name a specific operation
inside a function. i am using the if(cond){}else{}
construction and would like to name it. However if i
do assign a name to it and then call it later onm in
the function, it is not recognised. does any one have
any idea why?
Thank you,
Dave
#
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:

            
#
Functions can be defined within (i.e. local to) functions.  If you are 
more specific about what you did, it would be easier for others to help.

Spencer Graves
Dave Caccace wrote: