taxaBreadth: Metrics identifying the breadth and proportion of taxa...

Description Usage Arguments Value Examples

View source: R/taxaBreadth.R

Description

These metrics describe the 'experience' the recorder has had recording species within the group.

Usage

1
2
3
4
5
6
taxaBreadth(
  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

Value

A data.frame with four columns is returned.

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
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
## Not run: 

# load example data
head(cit_sci_data)

TB <- taxaBreadth(recorder_name = 3007,
data = cit_sci_data,
sp_col = 'species',
recorder_col = 'recorder')

head(TB)

# Run for more than one recorder, this can be slow 
TB_all <- lapply(unique(cit_sci_data$recorder),
                 FUN = taxaBreadth, 
                 data = cit_sci_data, 
                 sp_col = 'species',
                 recorder_col = 'recorder')

# summarise as one table
TB_all_sum <- do.call(rbind, TB_all)

hist(TB_all_sum$taxa_prop, breaks = 40)

## Accounting for spatial restriction in movement
If recorders where restricted to the countries that
make up GB (Scotland England and Wales). We should
analyse the data by country
library(sp)
plot(GB)

# Convert our citizen science data to a SpatialPointsDataframe
SP <- SpatialPointsDataFrame(data = cit_sci_data,
                             coords = cit_sci_data[,c('long','lat')])
# Define lat long coordinate system
CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
proj4string(SP) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")

# Empty object for all results
TB_all_countries <- NULL

# Loop through counties
for(i in unique(GB$NAME)){
  
  # Subset by country
  SP_C <- SP[GB[GB$NAME == i, ], ]
  
  # Calculate the metric within country
  TB_one_country <- lapply(unique(SP_C$recorder),
                           FUN = taxaBreadth,
                           data = SP_C@data,
                           sp_col = 'species',
                           recorder_col = 'recorder')
  
  # combine data
  TB_one_country <- do.call(rbind, TB_one_country)
  TB_one_country$country <- i
  TB_all_countries <- rbind(TB_all_countries,
                            TB_one_country)
}

# Note that recorders that have recorded in more than
# one country are replicated in our results (n = 75)
sum(table(TB_all_countries$recorder) > 1)


# Alternativly we can subset data by a buffer around the 
# recorders records, rather than by country.
# Here I use a buffer of 30km
library(raster)
library(rgeos)

# Empty object for all results
TB_all_30km_buffer <- NULL

for(i in unique(SP$recorder)){
  
  SP_R <- SP[SP$recorder == i, ]
  SP_R_buffer <- buffer(SP_R, 30000)  
  SP_P <- SP[SP_R_buffer, ]
  
  TB_one_buffer <- taxaBreadth(recorder_name = i,
                               data = SP_P@data,
                               sp_col = 'species',
                               recorder_col = 'recorder')
  
  TB_all_30km_buffer <- rbind(TB_all_30km_buffer,
                              TB_one_buffer)
}

# Compare results with original analysis
combo <- merge(y = TB_all_30km_buffer,
               x = TB_all_sum, 
               by = 'recorder')

plot(combo$taxa_prop.x,
     combo$taxa_prop.y,
     xlab = 'Original',
     ylab = 'By buffer',
     main = 'Proportion of taxa recorded')
abline(0,1)


## End(Not run) 

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