[R] if else statements in R

Timur Elzhov Timur.Elzhov at jinr.ru
Mon Jun 30 17:47:25 CEST 2003


On Mon, Jun 30, 2003 at 11:21:52AM -0400, Michael Rennie wrote:

> W<- function(w)
> {
> if (comp[i,1]=1) W[i]<-Wo else
"==" is comparison operator, but "=" is assignment one.
This code also doesn't work:

> x <- 0
> if (x = 1)
Error: syntax error

But this works:
> if (x == 1)
+ 

Chack also help("=="), help("=")

--
WBR,
Timur.




More information about the R-help mailing list