[R-sig-eco] Species CoOccurance

Tyler Smith tyler.smith at eku.edu
Fri Mar 12 16:19:03 CET 2010


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



More information about the R-sig-ecology mailing list