[R] number of shared species between sites (VEGAN or RICH?)

peter dalgaard pdalgd at gmail.com
Mon Jul 9 22:39:58 CEST 2012


On Jul 9, 2012, at 21:26 , Rui Barradas wrote:

> Hello,
> 
> So you want to split data.frame 'dat' by the values of the first column, named 'site', and return the other columns.
> 
> 
> lapply(split(dat, dat[[ 1 ]]), function(x) x[-1])
> 

Got to be easier to split(dat[-1], dat[[1]]), no?

-pd

> 
> Hope this helps,
> 
> Rui Barradas
> 
> Em 09-07-2012 13:27, elpape escreveu:
>> Dear all
>> 
>> I'm trying to calculate the number of shared species between sites.
>> 
>> I have a dataframe with in the first column the names of the sites; the
>> names of the other columns are the species names. To use the shared function
>> from the package RICH one needs to input different matrices. So actually, I
>> want to split the dataframe per row so that each row becomes a separate
>> matrix and then perform the shared function. I used split(dataframe,
>> site_name), which splits the dataframe, but I cannot call the separate
>> matrices to calculate the number of shared species..
>> 
>> Does anyone know a way to do this? Or does somebody know a better way of
>> determining this?
>> 
>> Thanks!
>> Ellen
>> 
>> --
>> View this message in context: http://r.789695.n4.nabble.com/number-of-shared-species-between-sites-VEGAN-or-RICH-tp4635843.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list