Re: [R] problem with simple if() statement

From: justin bem <justin_bem_at_yahoo.fr>
Date: Fri 10 Feb 2006 - 06:32:10 EST


Hi Norman !  

I observe that R syntax is very close to C/C++ or Java

> Norman Goodacre wrote:
> > the following code apprantely, for some grand old
> reason, induces a syntax error:
> >
> > if (seq[i] = "A") m <- trans[1,]
> >
> > where seq is a vector and trans is a matrix. I
> cannot for the life of me see why this is wrong.
> Syntax error is:
> >
> > Error: syntax error in "if (seq[i] ="
> >
> > Sincerely,
> >
> > Norman Goodacre
>
> Please, read "An Introduction to R" provided with
> any version of R. The
> correct syntax for an equality condition is "==",
> not "=", so:
>
> > if (seq[i] == "A") ....
>
> Best,
>
> Philippe Grosjean
>
> ______________________________________________
> R-help@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
>



R-help@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 Received on Fri Feb 10 08:25:33 2006

This archive was generated by hypermail 2.1.8 : Sat 11 Feb 2006 - 03:08:11 EST