allBiodiversity: Calculates all Biodiversity indicators

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/allBiodiversity.R

Description

This function calculates all (or a subset) of the Biodiversity indicators for j areas and i years. The user can choose whether the function returns the indicator dataframe to the global environment, exports the dataframe to a csv file, or both. The user can also choose whether the function returns the raw indicator values, the standardized (z-score) values, or both.

Usage

1
2
3
4
allBiodiversity(X, metric = "ABUNDANCE", groups = "ALL",
  species.table = NULL, TL.table, percentiles = c(0.25, 0.75),
  minTL = 0, years, raw = TRUE, std = TRUE, glob.env = TRUE,
  export.path = NULL, export.id = NULL)

Arguments

X

A dataframe of fishery independent data derived from research vessel survey data or model output, with columns YEAR, ID, SPECIES, and ABUNDANCE. YEAR indicates the year the observation was recorded, ID is an area code indicating where the observation was recorded, SPECIES is a numeric code indicating the species sampled, and ABUNDANCE is the corresponding abundance (stratified and corrected for catchability as required).

metric

A character string indicating which column in X to use to calculate the indicators. Default is metric = "ABUNDANCE".

groups

A vector indicating the species group(s) for which to calculate the indicators. If groups = "ALL", all species will be included; otherwise, each entry must be a character string matching the name of a column in species.table. Default is groups = "ALL".

species.table

A table where the column names match the entries in groups. Column entries are species codes indicating the species from X included in each group. species.table may also include columns for other species groups; these will be ignored. If groups = "ALL", this table is not required. Default is species.table = NULL.

TL.table

A dataframe with columns SPECIES and the corresponding TL (trophic level). Entries in the SPECIES column should be the unique values of species codes in X (or a subset thereof). Other columns in TL.table are ignored. If TL.table = NULL, Kempton's Q will not be calculated.

percentiles

The percentiles used to determine R1 and R2 for calculating Kempton's Q. Default is percentiles = c(0.25, 0.75).

minTL

Minimum trophic level for species included to calculate Kempton's Q. Default is minTL = 0.

years

A vector of years for which to calculate indicators.

raw

A logical value. If raw = TRUE, the raw indicator values are returned by the function. If raw = FALSE, the raw indicator values are not returned. Default is raw = TRUE. Either raw or std must be TRUE.

std

A logical value. If std = TRUE, the standardized indicator values for each area ID are returned by the function. Indicators are standardized using z-scores, i.e., by subtracting the mean and dividing by the standard deviation (ignoring NA values). If std = FALSE, the standardized indicator values are not returned. Default is std = TRUE. Either raw or std must be TRUE.

glob.env

Logical value indicating whether to return output to global environment. Default is glob.env = TRUE.

export.path

File path indicating where to save a .csv file of calculated indicators (named biodiversity_export.id.csv; see below). If export.file = NULL, the indicator dataframe will not be exported as a .csv file. Default is export.path = NULL.

export.id

Character string to modify the name of the .csv file (if export.path is specified), for example an area name or date of analysis. The exported .csv file is named biodiversity_export.id.csv. Default is export.id = NULL.

Details

This function calculates the Biodiversity indicators: Species Richness, Shannon's Index of Diversity, Margalef's Species Richness, Pielou's Species Evenness, Hill's N1, Hill's N2, Heip's Evenness Index, and Kempton's Q. If trophic level data are not available to calculate Kempton's Q, the remaining Biodiversity indicators will be returned. See the help file for the individual functions for information on how each indicator is calculated.

Notes on indicator calculations: In the individual functions, the user generally has control over which metric (e.g., "BIOMASS" or "ABUNDANCE") and group (e.g., "ALL" or "GROUNDFISH") are used to calculate the indicator. Here, the same metric and group are used to calculate each indicator. Defaults are metric = "ABUNDANCE" and group = "ALL".

Value

Returns a dataframe with columns ID, YEAR, and indicators corresponding to the arguments supplied to the function. Standardized indicators are noted with _s in the name.

Author(s)

Danielle Dempsey Danielle.Dempsey@dfo-mpo.gc.ca, Adam Cook, Catalina Gomez, Alida Bundy

See Also

Other biodiversity indicators: heips, hillN1, hillN2, kemptonQ, margalef, pielouEvenness, shannon, speciesRichness

Examples

1
2
3
4
5
data(X)

# Calculate raw and standardized indicators
allBiodiversity(X = X, metric = "ABUNDANCE", groups = "ALL", TL.table = species.info,
   percentiles = c(.25, 0.75), minTL = 0, years = c(2014:2019), raw = TRUE, std = TRUE)

Example output

      ID YEAR SpeciesRichness_ALL ShannonDiversity_ALL MargalefRichness_ALL
1  AREA1 2014                 153             1.832029             6.197670
2  AREA1 2015                 190             2.043576             7.702378
3  AREA1 2016                 191             1.723573             7.717426
4  AREA1 2017                 200             2.123325             8.265226
5  AREA1 2018                 187             2.206637             7.754668
6  AREA1 2019                 196             1.426820             7.842566
7  AREA2 2014                 161             2.018822             6.726931
8  AREA2 2015                 150             2.130908             6.420818
9  AREA2 2016                 151             1.920664             6.376422
10 AREA2 2017                 143             2.002370             6.143174
11 AREA2 2018                 140             1.579645             5.850146
12 AREA2 2019                 141             1.797358             6.054704
   PielouEvenness_ALL HillDiversity_ALL HillDominance_ALL  Heips_ALL
1           0.3641888          6.246549          3.951117 0.03451677
2           0.3894733          7.718159          3.903130 0.03554582
3           0.3281575          5.604518          3.174042 0.02423430
4           0.4007546          8.358885          4.679784 0.03697932
5           0.4218297          9.085114          5.597405 0.04346835
6           0.2703277          4.165434          2.447229 0.01623299
7           0.3972961          7.529450          4.886472 0.04080906
8           0.4252770          8.422510          3.987204 0.04981550
9           0.3828098          6.825488          4.597779 0.03883658
10          0.4034722          7.406587          4.387534 0.04511681
11          0.3196600          4.853233          3.031386 0.02772110
12          0.3631935          6.033683          3.118748 0.03595488
   KemptonQ_0_ALL SpeciesRichness_ALL_s ShannonDiversity_ALL_s
1        13.12902           -1.96336120            -0.20824764
2        15.15009            0.22692114             0.51834679
3        15.66883            0.28611796            -0.58075955
4        15.71705            0.81888935             0.79225918
5        13.13195            0.04933068             1.07840945
6        16.62034            0.58210207            -1.60000823
7        14.80901            1.66840550             0.56536998
8        13.31722            0.29197096             1.13871095
9        12.48471            0.41710137             0.06327215
10       10.57121           -0.58394192             0.48121355
11       11.35864           -0.95933316            -1.68110391
12       13.33981           -0.83420275            -0.56746272
   MargalefRichness_ALL_s PielouEvenness_ALL_s HillDiversity_ALL_s
1              -1.9495666           0.03124724         -0.33293655
2               0.1726122           0.48700578          0.46171826
3               0.1938362          -0.61822413         -0.67962724
4               0.9664297           0.69035296          0.80770367
5               0.2463608           1.07023672          1.19985988
6               0.3703278          -1.66061858         -1.45671801
7               1.4985953           0.41582955          0.54445706
8               0.5118423           1.17409343          1.25502126
9               0.3687338           0.02326120         -0.01565095
10             -0.3831397           0.58319791          0.44670105
11             -1.3277109          -1.68805644         -1.58487726
12             -0.6683208          -0.50832565         -0.64565116
   HillDominance_ALL_s Heips_ALL_s KemptonQ_0_ALL_s
1          -0.00693690   0.2731363       -1.2215760
2          -0.05035106   0.3777329        0.1702418
3          -0.70996705  -0.7720179        0.5274729
4           0.65229741   0.5234404        0.5606803
5           1.48248123   1.1830134       -1.2195552
6          -1.36752364  -1.5853051        1.1827361
7           1.14088571   0.1441583        1.4196688
8          -0.01845729   1.3244037        0.4402009
9           0.76870128  -0.1143239       -0.1064005
10          0.49765150   0.7086653       -1.3627534
11         -1.25070507  -1.5709476       -0.8457487
12         -1.13807613  -0.4919558        0.4550329

marindicators documentation built on Nov. 12, 2019, 5:07 p.m.