Hello,

Try

x <- c(1,0,21,2,0,0,234,2,0)
as.integer(x != 0)

Hope this helps,

Rui Barradas


Em 31-05-2012 12:13, Johannes Radinger escreveu:
Hi,

I am looking for a very easy way to transform
a column in a dataframe from counts (eg. c(1,0,21,2,0,0,234,2,0))
into a binary form to get presence/absence values
e.g. c(1,0,1,1,0,0,1,1,0). Is there a simple built-in function?
or do I have do to it with a replaceement funciton using IF x>  0
THEN 1 etc.?

/johannes

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to