...@r-project.org wrote on 02/12/2013 04:19:09 PM:
From: MARCELINO DE LA CRUZ ROT marcelino.delac...@upm.es
To: r-sig-ecology@r-project.org
Date: 02/12/2013 04:20 PM
Subject: Re: [R-sig-eco] How do I convert a matrix from abundant
into presence/absence data?
Sent by: r-sig-ecology-boun...@r
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
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
marcelino.delac...@upm.es
To: r-sig-ecology@r-project.org
Date: 02/12/2013 04:20 PM
Subject: Re: [R-sig-eco] How do I convert a matrix from abundant
into presence/absence data?
Sent by: r-sig-ecology-boun...@r-project.org
Let's say your matrix or data.frame is named M
M[M0] -1
Now M is only 0's