[R] numbers not behaving as expected

Stavros Macrakis macrakis at alum.mit.edu
Thu Apr 9 20:35:19 CEST 2009


On Thu, Apr 9, 2009 at 2:05 PM,  <Steve_Friedman at nps.gov> wrote:
> WetMonths <- Cell.ave[Cell.ave$month  >= "5" and Cell.ave$month <= "11",]
> Error: unexpected symbol in "WetMonths <- Cell.ave[Cell.ave$month  >= "5"
> and"  Cell.ave$month <= "11",]

a) you are comparing with the *string* "5", not the *number* 5 (as I
mentioned before)
b) you are now writing "and" rather than "&"

The following works fine for me:

WetMonths <- Cell.ave[Cell.ave$month  >=  5 & Cell.ave$month <= 11,]

Better?

         -s




More information about the R-help mailing list