speciesRarity: Calculate the rarity of species recorded by a volunteer

Description Usage Arguments Details Value Examples

View source: R/speciesRarity.R

Description

This function takes in data for a recorder and calculates the recorder's rarity metrics.

Usage

1
2
3
4
5
6
speciesRarity(
  recorder_name,
  data,
  sp_col = "preferred_taxon",
  recorder_col = "recorders"
)

Arguments

recorder_name

the name of the recorder for whom you want to calculate the metrics

data

the data.frame of recording information

sp_col

the name of the column that contains the species names

recorder_col

the name of the column that contains the recorder names

Details

This function examines the rarity of the species that a recorder observes and compares this to the rarity of species recorded across all recorders. First all species are ranked by rarity across all observations from all recorders. These ranks are then scaled to 100 so that the metrics are independent of the number of species in the group. Each observation, in the entire dataset is then assigned a value for the ranked rarity of the species observed and a median is calculated. This median is therefore the median ranked rarity of species observed, where 1 is the most common species and 100 the rarest (ranks are scaled to 100). The median rarity for the individual recorder is calculated in the same way, but using the species' rank values from the overall dataset.

Value

A data.frame with seven columns

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 

# load example data
head(cit_sci_data)

# Run for a single recorder
SR <- speciesRarity(recorder_name = 3007,
                   data = cit_sci_data, 
                   sp_col = 'species',
                   recorder_col = 'recorder')
                   
# Run the metric for all recorders
SR_all <- lapply(unique(cit_sci_data$recorder),
                 FUN = speciesRarity,
                 data = cit_sci_data,
                 sp_col = 'species',
                 recorder_col = 'recorder')

# summarise as one table
SR_all_sum <- do.call(rbind, SR_all)

hist(SR_all_sum$median_diff_rarity, breaks = 20) 

## End(Not run)

BiologicalRecordsCentre/recorderMetrics documentation built on Nov. 10, 2021, 2:03 p.m.