[R] How to calculate the index "the number of speciescombinations"?

Bill.Venables at csiro.au Bill.Venables at csiro.au
Sun Jul 8 03:05:13 CEST 2007


Here is a step by step explanation.  

The way you present the data is as species (rows) by sites (columns)
data frame

> dim(species_x_sites)
[1] 17 20

There are in fact only 19 sites as one of the columns of the data frame
is the species name:

> names(species_x_sites)
 [1] "Species"      "Cuba"         "Hispaniola"   "Jamaica"
"Puerto_Rico" 
 [6] "Guadeloupe"   "Martinique"   "Dominica"     "St._Lucia"
"Barbados"    
[11] "St._Vincent"  "Grenada"      "Antigua"      "St._Croix"
"Grand_Cayman"
[16] "St._Kitts"    "Barbuda"      "Montserrat"   "St._Martin"
"St._Thomas"  

To use the standard tools you need to turn it around and make a
site_x_species matrix

> site_x_species <- t(as.matrix(species_x_sites[, -1]))

(The [, -1] simply omits the species column and the t() transoses it)

> dim(site_x_species)
[1] 19 17

Now how many unique combinations are there?

> unique_combos <- unique(site_x_species) # unique *rows*

Not to find out how many we could use

> dim(unique_combos)
[1] 10 17

or

> nrow(unique_combos)
[1] 10

Which I believe corresponds to your index.



-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Zhang Jian
Sent: Saturday, 7 July 2007 4:20 PM
To: Sarah Goslee; r-help
Subject: Re: [R] How to calculate the index "the number of
speciescombinations"?

Sorry, I can not understand your reply very clearly.
How to compute the number of unique sites ?
Can you give me a simply example or do a simply analyse using one data?
Thanks very much.
                                       Jian Zhang


On 7/7/07, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>
> It should be the number of unique sites. In this case, the number of
> unique columns in the data frame. See ?unique. (Interestingly,
> convention is usually that species are columns and sites are rows.)
>
> For your sample data you only see 10 of the 2^17 possible combinations
> of 17 species (not 2n).
>
> Sarah
>
> On 7/7/07, Zhang Jian <jzhang1982 at gmail.com> wrote:
> > I want to analyze the co-occurrence of some species. In some papers,
the
> > authors said that the index"the number of species combinations
(COMBO)"
> is a
> > good index. I try to calculate the index by R language. But I can
not
> get
> > the right value. I think that I do not understand the concept of the
> index
> > because my english is not good.
> >
> > The concept:
> > *The number of species combinations   *This index scans the columns
of
> the
> > presence-absence matrix and keeps track of the number of unique
species
> > combinations that are represented in different sites. For an
assemblage
> of n
> > species, there are 2n possible species combinations, including the
> > combination of no species being present (Pielou and Pielou 1968). In
> most
> > real matrices, the number of sites (= columns) is usually
substantially
> less
> > than 2n, which places an upper bound on the number of species
> combinations
> > that can be found in both the observed and the simulated matrices.
> >
> > Presence-absence Data (Each row represents different species and
each
> column
> > represents a different site. A "1" indicates a species is present at
a
> > particular site, and a "0" indicates that a species is absent from a
> > particular site):
> > Species Cuba Hispaniola Jamaica Puerto_Rico Guadeloupe Martinique
> Dominica
> > St._Lucia Barbados St._Vincent Grenada Antigua St._Croix
Grand_Cayman
> > St._Kitts Barbuda Montserrat St._Martin St._Thomas
> > Carduelis_dominicensis 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Loxia_leucoptera 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Volatinia_jacarina 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
> > Sporophila_nigricollis 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
> > Melopyrrha_nigra 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
> > Loxigilla_portoricensis 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Loxigilla_violacea 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Loxigilla_noxis 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0
> > Melanospiza_richardsoni 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
> > Tiara_olivacea 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
> > Tiara_bicolor 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1
> > Tiara_canora 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Loxipasser_anoxanthus 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Saltator_albicollis 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
> > Torreornis_inexpectata 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Ammodramus_savannarum 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > Zonotrichia_capensis 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list