Skip to content

Species CoOccurance

5 messages · Lanna Jin, Peter Solymos, Wilfried Thuiller +1 more

#
Lanna,

I don't know exactly what do you mean by co-occurrence data frame, but
if you'd like to get a species-by-species matrix, in which you count
the co-occurrences of the species (columns in the sites-by-species
community matrix) with each other, you can use the crossprod function
or the %*% operator for a presence/absence matrix:

m <- matrix(rbinom(15,1,0.6),5,3)
t(m) %*% m
crossprod(m, m)

HTH,

Peter
On Fri, Mar 12, 2010 at 7:22 AM, Lanna Jin <lannajin at gmail.com> wrote:
#
Lanna Jin <lannajin at gmail.com> writes:
mydata$cooccur <- mydata$SpeciesA & mydata$SpeciesB

Where 'mydata' is the name of your dataframe.

Tyler