Skip to content
Prev 296227 / 398503 Next

Transform counts into presence/absence

Hello,

Actually, your output is wrong, you have compared the elements of a 'x', 
not Counts, to 0.

 > Counts <- c(1,0,21,2,0,0,234,2,0,NA)
 > Counts > 0
  [1]  TRUE FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE FALSE    NA
 > 1 *(Counts > 0)
  [1]  1  0  1  1  0  0  1  1  0 NA
 > as.integer(Counts != 0)
  [1]  1  0  1  1  0  0  1  1  0 NA

Anyway, I hadn't thought of that. It's good to know how they behave.

Rui Barradas

Em 31-05-2012 23:58, Duncan Mackay escreveu: