An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20100312/90a43d5d/attachment.pl>
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:
Hello All, I've been sifting through tons of R Documentation, trying to find a command that converts a community matrix dataset into a species pair co-occurance data frame, and have failed miserably to find one. ?Does a function already exist in one of the community analysis packages? Thanks in advance for your response! -- Lanna Jin lannajin at gmail.com 510-898-8525 ? ? ? ?[[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20100312/53f8370f/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20100312/b95f564e/attachment.pl>
Lanna Jin <lannajin at gmail.com> writes:
Hi Peter, Thanks for your quick response. I am working with a dataframe that has columns of Year, Location, Type (pertains to type of location), Species, and Presence/Absence. What I'm interested in doing is generating a data frame that would not lose the "Year" , "Location" and "Type" data. I would ultimately like it to have the columns: "Year", "Location", "Type", "SpeciesA", "SpeciesB", and "Co-occurance", where Co-occurance is either a 0 or 1 for if the species co-occur at the particular location at that exact particular point in time. Is there a function that exists out there that could quickly convert my data into this form? Or do I have to generate my own?
mydata$cooccur <- mydata$SpeciesA & mydata$SpeciesB Where 'mydata' is the name of your dataframe. Tyler