[R-sig-eco] How do I convert a matrix from abundant into presence/absence data?
Sarah Goslee
sarah.goslee at gmail.com
Tue Feb 12 22:08:14 CET 2013
Assuming you have nothing unusual going on, here are some example data
and one possible solution:
> mydata <- data.frame(A=c(0, 10, 25), B=c(1, 5, 15), C=c(3, 0, 0))
> mydata
A B C
1 0 1 3
2 10 5 0
3 25 15 0
> mydata[mydata > 0] <- 1
> mydata
A B C
1 0 1 1
2 1 1 0
3 1 1 0
On Tue, Feb 12, 2013 at 4:04 PM, Cory Redman <corymredman at gmail.com> wrote:
> I am sure there is any easy solution to this, but due to my
> monkey-level understanding of R, I need some help and can't seem to
> find the answer to my question via the web.
>
> I have been successful in importing an abundance dataset (taxa = rows,
> sample sites = columns) into R, but I want to rerun some analyses by
> converting this dataset into presence/absence data, How do I do this?
>
> Cheers,
> Cory
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-sig-ecology
mailing list