Skip to content

Making an if condition variable ?

2 messages · ce, Rainer M Krug

ce
#
Thank you all for wisdom :)
Problem is that I change the condition often and then I forget it. I wanted to put it at the beginning of the program with the other parameters so I wouldn't miss it. 

ce


-----Original Message-----
From: "Rainer M Krug" [Rainer at krugs.de]
Date: 06/02/2016 04:00 AM
To: "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us>
CC: r-help at r-project.org
Subject: Re: Making an if condition variable ?

Jeff Newmiller <jdnewmil at dcn.davis.ca.us> writes:
+1

I think this a very common pitfall (I know it from own experience...)
and I would say a candidate for a fortune?

Rainer
#
"ce" <zadig_1 at excite.com> writes:
In this case - why not use a function instead of the condition?

cond <- function(x){x>0}
and than

if (cond(4)) {...}

might be the easiest in this case?

or, more flexible,

cond <- function(...){x>0}

if (cond(x=3)) {...}

Cheers,

Rainer