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?

Thanks!
Lanna

2010/3/12 Peter Solymos <soly...@ualberta.ca>

> 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 <lanna...@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
> >
> > lanna...@gmail.com
> > 510-898-8525
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-ecology mailing list
> > R-sig-ecology@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> >
> >
>



-- 
Lanna Jin

lanna...@gmail.com
510-898-8525

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to