[R] if else statement

Petr Pikal petr.pikal at precheza.cz
Fri Jan 19 14:39:53 CET 2007


Hi

also note the difference between if and ifelse. The former is similar 
to other languages

if (true or false codition) {do this} else {do that}

but

ifelse(logical vector, vector for true elements, vector for false 
elements)

see corespondent help pages.

HTH
Petr


On 18 Jan 2007 at 19:02, H. Paul Benton wrote:

Date sent:      	Thu, 18 Jan 2007 19:02:49 -0800
From:           	"H. Paul Benton" <hpbenton at scripps.edu>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] if else statement

> Hello,
> 
>     I'm doing some scripting and I've noticed that R doesn't seem to
> have an if (cond){
>     do
> }ifelse (cond) {
>     do
> } else {
>     do
> }
> 
> type block.
> 
> Is this correct or am I missing something.
> 
> THX
> 
> Paul
> 
> -- 
> Research Technician
> Mass Spectrometry
>    o The
>   /
> o Scripps
>   \
>    o Research
>   /
> o Institute
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

Petr Pikal
petr.pikal at precheza.cz



More information about the R-help mailing list