Skip to content
Prev 296221 / 398503 Next

Transform counts into presence/absence

Hi

I was curious on the possibilities -- what if an NA creeps in?

Counts <- c(1,0,21,2,0,0,234,2,0,NA)
Counts > 0
1 *(Counts > 0)
  [1]  1  0  1  1  0  0  1  1  0 NA

as.integer(x != 0)
[1] 1 0 1 1 0 0 1 1 0

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
At 21:27 31/05/2012, you wrote: