[R] Boolean expression

Jim Lemon drjimlemon at gmail.com
Mon Sep 14 13:19:02 CEST 2015

Hi Jue,
The character sequence "<-" is preferentially interpreted as "assign the
value on the right to the name on the left". You can use parentheses to
force the unary minus to be interpreted:


or you can just break the sequence with a space:

if(a< -1)

One less character, but perhaps easier to misread.


On Mon, Sep 14, 2015 at 9:10 PM, Jue Lin-Ye <jl.iccp at gmail.com> wrote:

> Dear fellow R users,
> I would like to discuss something. First of all, I would like to make clear
> that I think that the current R software is great.
> I have noticed that, for example, in the boolean expression "if(a<-1)", it
> is not clear if what is asked is "if 'a' is 1" or "if 'a' is lesser than
> -1". Should we just enclose "-1" within parentheses or should we have a
> more unequivocal syntax, here, like "a<$", "a<%"?
> Best regards,
> ​Jue
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list