Species diversity

Species acumulation curves, rarefaction and other plots

using packages vegan and iNext to analyze diversity on camera trap data
R
diversity
accumulation
effort
Author
Affiliation

Diego J. Lizcano

WildMon

Published

June 25, 2024

Species richness and sampling effort

There are two commonly used ways to account for survey effort when estimating species richness using camera traps:

  1. using the rarefaction of observed richness.

  2. using multispecies occupancy models to account for the species present but not observed (occupancy model).

In this post we can see an example of No 1. using the classical approach of community ecology using the vegan package. The vegan package (https://cran.r-project.org/package=vegan) provides tools for descriptive community ecology. It has basic functions of diversity analysis, community ordination and dissimilarity analysis. The vegan package provides most standard tools of descriptive community analysis. Later in the post we carry out another diversity analysis using functions of the package iNEXT.

The modern approach to measure species diversity include the “Sample Hill diversities” also known as Hill numbers. Rarefaction and extrapolation with Hill numbers have gain popularity in the last decade and can be computed using the function renyi in the R package vegan (Oksanen 2016) and the function rarity in the R package MeanRarity (Roswell and Dushoff 2020), and Hill diversities of equal-sized or equal-coverage samples can be approximately compared using the functions iNEXT and estimateD in the R package iNEXT (Hsieh et al. 2016). Estimates for asymptotic values of Hill diversity are available in SpadeR (Chao and Jost 2015, Chao et al. 2015).

Load packages

Code


library(patchwork) # The Composer of Plots
library(readxl) # Read Excel Files
library(sf) # Simple Features for R
library(elevatr) # Access Elevation Data from Various APIs
library(mapview) # Interactive Viewing of Spatial Data in R
library(tmap)
library(eks) # make countours
library(grateful) # Facilitate Citation of R Packages
library(camtrapR) # Camera Trap Data Management and Preparation of Occupancy and Spatial Capture-Recapture Analyses
library(vegan) # Community Ecology Package 
library(ggvegan)
# library(BiodiversityR) # cause error!
library(ggordiplots)
library(grid)
library(gridExtra)
library(DT)
library(MeanRarity)
library(SpadeR)
library(iNEXT) # Interpolation and Extrapolation for Species Diversity
library(knitr) # A General-Purpose Package for Dynamic Report Generation in R
library(kableExtra) # Construct Complex Table with 'kable' and Pipe Syntax
library(tidyverse) # Easily Install and Load the 'Tidyverse'
library(ggforce) # Accelerating 'ggplot2'
library(plotly)

Load data

Code

datos <- read_excel("C:/CodigoR/CameraTrapCesar/data/CT_Cesar.xlsx")

# habitat types extracted from Copernicus
habs <- read.csv("C:/CodigoR/CameraTrapCesar/data/habitats.csv")

Pooling together several sites

For this example I selected one year for the sites: Becerril 2021, LaPaz_Manaure 2019, MLJ, CL1, CL2 and PCF. Sometimes we need to make unique codes per camera and cameraOperation table. This was not the case.

For this example we are using the habitat type were the camera was installed as a way to see the sampling effort (number of cameras) per habitat type. Th habitat type was extracted overlaying the camera points on top of the Land Cover 100m global dataset from COPERNICUS using Google Earth engine connected to R. How to do this will be in another post.

Code
# make a new column Station
# datos_PCF <- datos |> dplyr::filter(Proyecto=="CT_LaPaz_Manaure") |> unite ("Station", ProyectoEtapa:Salida:CT, sep = "-")

# fix dates
datos$Start <- as.Date(datos$Start, "%d/%m/%Y")
datos$End <- as.Date(datos$End, "%d/%m/%Y")
datos$eventDate <- as.Date(datos$eventDate, "%d/%m/%Y")
datos$eventDateTime <- ymd_hms(paste(datos$eventDate, " ",
                              datos$eventTime, ":00", sep=""))

# filter Becerril
datos_Becerril <- datos |> dplyr::filter(ProyectoEtapa=="CT_Becerril") |> mutate (Station=IdGeo) |> filter(Year==2021)

# filter LaPaz_Manaure
datos_LaPaz_Manaure<- datos |> dplyr::filter(ProyectoEtapa=="CT_LaPaz_Manaure") |> mutate (Station=IdGeo) |> filter(Year==2019)

# filter MLJ
datos_MLJ <- datos |> dplyr::filter(ProyectoEtapa=="MLJ_TH_TS_2021") |> mutate (Station=IdGeo)

# filter CL
datos_CL1 <- datos |> dplyr::filter(ProyectoEtapa=="CL-TH2022") |> mutate (Station=IdGeo)
# filter CL
datos_CL2 <- datos |> dplyr::filter(ProyectoEtapa=="CL-TS2022") |> mutate (Station=IdGeo)

# filter PCF
datos_PCF <- datos |> dplyr::filter(Proyecto=="PCF") |> mutate (Station=IdGeo)

data_south <- rbind(datos_LaPaz_Manaure, datos_Becerril, datos_MLJ,datos_CL1, datos_CL2,datos_PCF)

# filter 2021 and make uniques
CToperation  <- data_south |> 
              # filter(Year==2021) |> 
              group_by(Station) |> 
              mutate(minStart=min(Start), maxEnd=max(End)) |>  distinct(Longitude, Latitude, minStart, maxEnd, Year) |> 
  ungroup()

Generating the cameraOperation table and making detection histories for all the species.

The package CamtrapR has the function ‘cameraOperation’ which makes a table of cameras (stations) and dates (setup, puck-up), this table is key to generate the detection histories using the function ‘detectionHistory’ in the next step.

Code
# Generamos la matríz de operación de las cámaras

camop <- cameraOperation(CTtable= CToperation, # Tabla de operación
                         stationCol= "Station", # Columna que define la estación
                         setupCol= "minStart", #Columna fecha de colocación
                         retrievalCol= "maxEnd", #Columna fecha de retiro
                         #hasProblems= T, # Hubo fallos de cámaras
                         dateFormat= "%Y-%m-%d") #, # Formato de las fechas
                         #cameraCol="CT")
                         # sessionCol= "Year")

# Generar las historias de detección ---------------------------------------
## remove plroblem species
# ind <- which(datos_PCF$Species=="Marmosa sp.")
# datos_PCF <- datos_PCF[-ind,]

DetHist_list <- lapply(unique(data_south$Species), FUN = function(x) {
  detectionHistory(
    recordTable         = data_south, # Tabla de registros
    camOp                = camop, # Matriz de operación de cámaras
    stationCol           = "Station",
    speciesCol           = "Species",
    recordDateTimeCol    = "eventDateTime",
    recordDateTimeFormat  = "%Y-%m-%d",
    species              = x,     # la función reemplaza x por cada una de las especies
    occasionLength       = 7, # Colapso de las historias a 10 días
    day1                 = "station", # ("survey"),or #inicia en la fecha de cada station
    datesAsOccasionNames = FALSE,
    includeEffort        = TRUE,
    scaleEffort          = FALSE,
    output               = ("binary"), # ("binary") or ("count")
    #unmarkedMultFrameInput=TRUE
    timeZone             = "America/Bogota" 
    )
  }
)

# put names to the species 
names(DetHist_list) <- unique(data_south$Species)

# Finally we make a new list to put all the detection histories.
ylist <- lapply(DetHist_list, FUN = function(x) x$detection_history)


  

Use the detection histories to make the a matrix for vegan and the incidence for iNEXT.

Species accumulation curves made using the package vegan, plot the increase in species richness as we add survey units. If the curve plateaus (flattens), then that suggests you have sampled the majority of the species in your survey site (camera or habitat type).

Code
# loop to make vegan matrix
mat_vegan <- matrix(NA, dim(ylist[[1]])[1], length(unique(data_south$Species)))
for(i in 1:length(unique(data_south$Species))){
  mat_vegan[,i] <- apply(ylist[[i]], 1, sum, na.rm=TRUE)
  mat_vegan[,i] <- tidyr::replace_na(mat_vegan[,i], 0) # replace na with 0
}

colnames(mat_vegan)  <- unique(data_south$Species)
rownames(mat_vegan) <- rownames(ylist[[1]])

mat_vegan2 <- as.data.frame(mat_vegan)
mat_vegan2$hab <- habs$hab_code
# mat_vegan3 <-  mat_vegan2 |> 
  
# Select specific rows by row numbers
closed_forest_rows <- which(mat_vegan2$hab=="closed_forest_evergreen_broad")
herbaceous_rows <- which(mat_vegan2$hab=="herbaceous_wetland")
herbs_rows <- which(mat_vegan2$hab=="herbs")
open_forest_rows <- which(mat_vegan2$hab=="open_forest_evergreen_broad")
open_forest2_rows <- which(mat_vegan2$hab=="open_forest_other")


closed_forest <- apply(mat_vegan2[closed_forest_rows,1:22], MARGIN = 2, sum)
herbaceous_wetland <- apply(mat_vegan2[herbaceous_rows,1:22], MARGIN = 2, sum)
herbs  <- apply(mat_vegan2[herbs_rows,1:22], MARGIN = 2, sum)
open_forest_evergreen <- apply(mat_vegan2[open_forest_rows,1:22], MARGIN = 2, sum)
open_forest_other <- apply(mat_vegan2[open_forest2_rows,1:22], MARGIN = 2, sum)

# tb_sp <- mat_vegan2 |> group_by(hab)
# hab_list <- group_split(tb_sp)

# make list of dataframe per habitat
sp_by_hab <- mat_vegan2 |> dplyr::group_by(hab) %>% split (.$hab)
# arrange abundance (detection frecuency) mat for INEXT 
cesar_sp <- t(rbind(
t(colSums(sp_by_hab[[1]][,1:33])),
t(colSums(sp_by_hab[[2]][,1:33])),
t(colSums(sp_by_hab[[3]][,1:33])),
t(colSums(sp_by_hab[[4]][,1:33])),
t(colSums(sp_by_hab[[5]][,1:33]))
))
 
colnames(cesar_sp) <- names(sp_by_hab)



# function to Format data to incidence and use iNext
f_incidences <- function(habitat_rows=closed_forest_rows){ylist %>%  # historias de detection
  map(~rowSums(.,na.rm = T)) %>% # sumo las detecciones en cada sitio
  reduce(cbind) %>% # unimos las listas
  as_data_frame() %>% #formato dataframe
  filter(row_number() %in% habitat_rows) |> 
  t() %>% # trasponer la tabla
  as_tibble() %>% #formato tibble
  mutate_if(is.numeric,~(.>=1)*1) %>%  #como es incidencia, formateo a 1 y 0
  rowSums() %>%  # ahora si la suma de las incidencias en cada sitio
  sort(decreasing=T) |> 
  as_tibble() %>% 
  add_row(value= length(habitat_rows), .before = 1) %>%  # requiere que el primer valor sea el número de sitios
  filter(!if_any()==0) |>  # filter ceros
  as.matrix() # Requiere formato de matriz
}

# Make incidence frequency table (is a list whit 5 habitats)
# Make an empty list to store our data
incidence_cesar <- list() 
incidence_cesar[[1]] <- f_incidences(closed_forest_rows)
incidence_cesar[[2]] <- f_incidences(herbaceous_rows)
incidence_cesar[[3]] <- f_incidences(herbs_rows)
incidence_cesar[[4]] <- f_incidences(open_forest_rows)
incidence_cesar[[5]] <- f_incidences(open_forest_other)

# put names
names(incidence_cesar) <- names(sp_by_hab)

# we deleted this habitat type for making error
incidence_cesar <- within(incidence_cesar, rm("herbaceous_wetland")) 

To start lets plot the species vs sites

Code
# Transpose if needed to have sample site names on rows
abund_table<-mat_vegan
# Convert to relative frequencies
abund_table <- abund_table/rowSums(abund_table)
library(reshape2)
df<-melt(abund_table)
colnames(df)<-c("Sampled_site","Species","Value")
library(plyr)
library(scales)
 
# We are going to apply transformation to our data to make it
# easier on eyes 
 
#df<-ddply(df,.(Samples),transform,rescale=scale(Value))
df<-ddply(df,.(Sampled_site),transform,rescale=sqrt(Value))
 
# Plot heatmap
p <- ggplot(df, aes(Species, Sampled_site)) + 
  geom_tile(aes(fill = rescale),colour = "white") + 
  scale_fill_gradient(low = "white",high = "#1E5A8C")+
  scale_x_discrete(expand = c(0, 0)) +
  scale_y_discrete(expand = c(0, 0)) + theme(legend.position = "none",axis.ticks = element_blank(),axis.text.x = element_text(angle = 90, hjust = 1,size=6),axis.text.y = element_text(size=4))

# ggplotly(p) # see interactive
# View the plot
p

Notice how some cameras didn’t record any species. Here showed as the gay horizontal line. Perhaps we need to delete those cameras.

Rarefaction using vegan

Notice that sites are cameras and the acumulation is species per camera not time

Rarefaction is a technique to assess expected species richness. Rarefaction allows the calculation of species richness for a given number of individual samples, based on the construction of rarefaction curves.

The issue that occurs when sampling various species in a community is that the larger the number of individuals sampled, the more species that will be found. Rarefaction curves are created by randomly re-sampling the pool of N samples multiple times and then plotting the average number of species found in each sample (1,2, … N). “Thus rarefaction generates the expected number of species in a small collection of n individuals (or n samples) drawn at random from the large pool of N samples.”. Rarefaction curves generally grow rapidly at first, as the most common species are found, but the curves plateau as only the rarest species remain to be sampled.

Code

rarecurve(mat_vegan, col = "blue") 

Code
rarecurve(t(cesar_sp), col = "blue") 

Code

sp1 <- specaccum(mat_vegan)
sp2 <- specaccum(mat_vegan, "random")
# sp2
# summary(sp2)
plot(sp1, ci.type="poly", col="blue", lwd=2, ci.lty=0, ci.col="lightblue")

Code
# boxplot(sp2, col="yellow", add=TRUE, pch="+")


mods <- fitspecaccum(sp1, "gleason")
plot(mods, col="hotpink")
boxplot(sp2, col = "yellow", border = "blue", lty=1, cex=0.3, add= TRUE)

Code


## Accumulation model
pool <- poolaccum(mat_vegan)
# summary(pool, display = "chao")
plot(pool)

Ranked abundance distribution

An alternative approach to species abundance distribution is to plot logarithmic abundances in decreasing order, or against ranks of species.

Code
k <- sample(nrow(mat_vegan), 1)
rad <- radfit(mat_vegan[22,]) # species 22
# plot(rad)
radlattice(rad)

Hill Diversities using vegan

Code
# data(BCI)
i <- sample(nrow(mat_vegan), 20)
mod <- renyi(mat_vegan) #selecting sites with more than one record
plot(mod)

Code
mod <- renyiaccum(mat_vegan[55:89,])
plot(mod, as.table=TRUE, col = c(1, 2, 2))

Code
persp(mod)

Total number of species

Code
DT::datatable(round(specpool(mat_vegan),3))

Number of unseen species per camera

Look at S.chao1

Code
DT::datatable(
t(round(as.data.frame(estimateR(mat_vegan[,])),3))
)
Code

# save as dataframe
S_per_site <- as.data.frame(t(round(as.data.frame(estimateR(mat_vegan[,])),3)))
# add sites
S_per_site$Station <- rownames(S_per_site)

It is weird to have .5 species in some sites.

Map it converting Cameratrap-operation to sf

In this step we convert the Cameratrap-operation table to sf, we add elevation from AWS, habitat type and species per site (S.chao1) to finally visualize the map showing the number of species as the size of the dot.

Code

# datos_distinct <- datos |> distinct(Longitude, Latitude, CT, Proyecto)

projlatlon <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

CToperation_sf <-  st_as_sf(x = CToperation,
                         coords = c("Longitude", 
                                    "Latitude"),
                         crs = projlatlon)

# write.csv(habs, "C:/CodigoR/CameraTrapCesar/data/habitats.csv")
habs <- read.csv("C:/CodigoR/CameraTrapCesar/data/habitats.csv")

CToperation_elev_sf <- get_elev_point(CToperation_sf, src = "aws") # get elevation from AWS

CToperation_elev_sf <- CToperation_elev_sf |> left_join(habs, by='Station') |> left_join(S_per_site, by='Station') |> select("Station", "elevation", "minStart.x","maxEnd.x", "Year.x", "hab_code" , "S.obs", "S.chao1")

# add habitat 
# CToperation_elev_sf$habs <- habs$hab_code
# see the map
mapview(CToperation_elev_sf, zcol="hab_code", cex = "S.chao1", alpha = 0)

Perhaps it is easyer to plot the species number as a countour map

One advantage of using the eks density estimate, is that it is clearer what the output means. The 20% contour means “20% of the measurements lie inside this contour”. The documentation for eks takes issue with how stat_density_2d does its calculation, I don’t know who is right because the estimated value is species.

Code
# select chao
species <- dplyr::select(CToperation_elev_sf, "S.chao1")
# hakeoides_coord <- data.frame(sf::st_coordinates(hakeoides))
Sta_den <- eks::st_kde(species) # calculate density

# VERY conveniently, eks can generate an sf file of contour lines
contours <- eks::st_get_contour(Sta_den, cont=c( 10,20,30,40,50,60,70,80, 90)) %>% 
  mutate(value=as.numeric(levels(contlabel)))


# pal_fun <- leaflet::colorQuantile("YlOrRd", NULL, n = 5)

p_popup <- paste("Species", as.numeric(levels(contours$estimate)), "number")


tmap::tmap_mode("view") # set mode to interactive plots

tmap::tm_shape(species) + 
    tmap::tm_sf(col="black", size=0.2) +
  #   contours from eks
  tmap::tm_shape(contours) +
    tmap::tm_polygons("estimate",
                      palette="Reds",
                      alpha=0.5 )
Code


## geom_sf plot
# ## suitable smoothing matrix gives optimally smoothed contours
# gs1 <- ggplot(Sta_den) + geom_sf(data=CToperation_elev_sf, fill=NA) + ggthemes::theme_map() +
#     colorspace::scale_fill_discrete_sequential(palette="Heat2") 
# gs1 + geom_sf(data=st_get_contour(Sta_den), aes(fill=label_percent(contlabel))) +
#     coord_sf(xlim=xlim, ylim=ylim) 

In general terms the species estimate per site seems to be larger near the mine and decrease with the distance to the mine. Also notice kernel density estimates are larger than s.chao1.

Nonmetric Multidimensional Scaling (NMDS)

Often in ecological research, we are interested not only in comparing univariate descriptors of communities, like diversity, but also in how the constituent species — or the species composition — changes from one community to the next. One common tool to do this is non-metric multidimensional scaling, or NMDS. The goal of NMDS is to collapse information from multiple dimensions (e.g, from multiple communities, sites were the cameratrap was installed, etc.) into just a few, so that they can be visualized and interpreted. Unlike other ordination techniques that rely on (primarily Euclidean) distances, such as Principal Coordinates Analysis, NMDS uses rank orders, and thus is an extremely flexible technique that can accommodate a variety of different kinds of data.

If the treatment is continuous, such as an environmental gradient, then it might be useful to plot contour lines rather than convex hulls. We can get some, elevation data for our original community matrix and overlay them onto the NMDS plot using ordisurf.

Code

example_NMDS=metaMDS(as.data.frame(mat_vegan), 
                     distance="euclidean",
                     zerodist = "ignore",
                     trymax=300,
                     k=5) # T
#> Wisconsin double standardization
#> Run 0 stress 0.1177774 
#> Run 1 stress 0.1188583 
#> Run 2 stress 0.1182867 
#> Run 3 stress 0.1178829 
#> ... Procrustes: rmse 0.05287032  max resid 0.2385686 
#> Run 4 stress 0.1196073 
#> Run 5 stress 0.1184047 
#> Run 6 stress 0.1192428 
#> Run 7 stress 0.1191299 
#> Run 8 stress 0.120843 
#> Run 9 stress 0.1200739 
#> Run 10 stress 0.1179485 
#> ... Procrustes: rmse 0.0615639  max resid 0.1917599 
#> Run 11 stress 0.1199474 
#> Run 12 stress 0.118847 
#> Run 13 stress 0.1189079 
#> Run 14 stress 0.1192798 
#> Run 15 stress 0.1196232 
#> Run 16 stress 0.11862 
#> Run 17 stress 0.1192976 
#> Run 18 stress 0.1190032 
#> Run 19 stress 0.1192681 
#> Run 20 stress 0.118402 
#> Run 21 stress 0.1204998 
#> Run 22 stress 0.1188755 
#> Run 23 stress 0.1191403 
#> Run 24 stress 0.11804 
#> ... Procrustes: rmse 0.06303234  max resid 0.2347508 
#> Run 25 stress 0.1187902 
#> Run 26 stress 0.1175395 
#> ... New best solution
#> ... Procrustes: rmse 0.07666867  max resid 0.3159852 
#> Run 27 stress 0.1186192 
#> Run 28 stress 0.1179992 
#> ... Procrustes: rmse 0.06716658  max resid 0.2630345 
#> Run 29 stress 0.1181853 
#> Run 30 stress 0.1221596 
#> Run 31 stress 0.1198705 
#> Run 32 stress 0.1190206 
#> Run 33 stress 0.1195645 
#> Run 34 stress 0.1180127 
#> ... Procrustes: rmse 0.07657627  max resid 0.2502429 
#> Run 35 stress 0.1177802 
#> ... Procrustes: rmse 0.07136113  max resid 0.2701777 
#> Run 36 stress 0.1194199 
#> Run 37 stress 0.1181979 
#> Run 38 stress 0.1187348 
#> Run 39 stress 0.1185976 
#> Run 40 stress 0.1199374 
#> Run 41 stress 0.1192169 
#> Run 42 stress 0.1221666 
#> Run 43 stress 0.1194566 
#> Run 44 stress 0.1209769 
#> Run 45 stress 0.1180201 
#> ... Procrustes: rmse 0.073283  max resid 0.3017499 
#> Run 46 stress 0.1187263 
#> Run 47 stress 0.1184455 
#> Run 48 stress 0.1192366 
#> Run 49 stress 0.1205404 
#> Run 50 stress 0.1197889 
#> Run 51 stress 0.1180383 
#> ... Procrustes: rmse 0.04036951  max resid 0.2345712 
#> Run 52 stress 0.1194803 
#> Run 53 stress 0.120894 
#> Run 54 stress 0.1193367 
#> Run 55 stress 0.120154 
#> Run 56 stress 0.1200085 
#> Run 57 stress 0.1206211 
#> Run 58 stress 0.1186259 
#> Run 59 stress 0.1181494 
#> Run 60 stress 0.1201826 
#> Run 61 stress 0.1193508 
#> Run 62 stress 0.1186022 
#> Run 63 stress 0.1183009 
#> Run 64 stress 0.1200911 
#> Run 65 stress 0.1185398 
#> Run 66 stress 0.1187113 
#> Run 67 stress 0.117739 
#> ... Procrustes: rmse 0.07603799  max resid 0.2876316 
#> Run 68 stress 0.1186278 
#> Run 69 stress 0.1190915 
#> Run 70 stress 0.1200617 
#> Run 71 stress 0.1191189 
#> Run 72 stress 0.1206133 
#> Run 73 stress 0.1206296 
#> Run 74 stress 0.1188916 
#> Run 75 stress 0.1198359 
#> Run 76 stress 0.1217497 
#> Run 77 stress 0.1184477 
#> Run 78 stress 0.1200407 
#> Run 79 stress 0.1193408 
#> Run 80 stress 0.1202349 
#> Run 81 stress 0.119949 
#> Run 82 stress 0.118728 
#> Run 83 stress 0.1199669 
#> Run 84 stress 0.11872 
#> Run 85 stress 0.1187594 
#> Run 86 stress 0.1207099 
#> Run 87 stress 0.1202514 
#> Run 88 stress 0.1192119 
#> Run 89 stress 0.117904 
#> ... Procrustes: rmse 0.07285597  max resid 0.2217598 
#> Run 90 stress 0.1182103 
#> Run 91 stress 0.1194068 
#> Run 92 stress 0.1192964 
#> Run 93 stress 0.1197348 
#> Run 94 stress 0.1181505 
#> Run 95 stress 0.1206419 
#> Run 96 stress 0.1200505 
#> Run 97 stress 0.1191712 
#> Run 98 stress 0.1185883 
#> Run 99 stress 0.1178277 
#> ... Procrustes: rmse 0.06965176  max resid 0.2321529 
#> Run 100 stress 0.1201769 
#> Run 101 stress 0.118646 
#> Run 102 stress 0.1210073 
#> Run 103 stress 0.1200804 
#> Run 104 stress 0.118894 
#> Run 105 stress 0.1199841 
#> Run 106 stress 0.1193176 
#> Run 107 stress 0.1192096 
#> Run 108 stress 0.1198388 
#> Run 109 stress 0.1202496 
#> Run 110 stress 0.1189517 
#> Run 111 stress 0.120284 
#> Run 112 stress 0.1182217 
#> Run 113 stress 0.1173101 
#> ... New best solution
#> ... Procrustes: rmse 0.07114129  max resid 0.2969946 
#> Run 114 stress 0.1188103 
#> Run 115 stress 0.1185651 
#> Run 116 stress 0.1206931 
#> Run 117 stress 0.1179989 
#> Run 118 stress 0.1204493 
#> Run 119 stress 0.1192954 
#> Run 120 stress 0.1185027 
#> Run 121 stress 0.1200907 
#> Run 122 stress 0.1188163 
#> Run 123 stress 0.1193817 
#> Run 124 stress 0.119878 
#> Run 125 stress 0.1192113 
#> Run 126 stress 0.1183022 
#> Run 127 stress 0.1196398 
#> Run 128 stress 0.11997 
#> Run 129 stress 0.1191586 
#> Run 130 stress 0.1192572 
#> Run 131 stress 0.1201811 
#> Run 132 stress 0.1188318 
#> Run 133 stress 0.1203068 
#> Run 134 stress 0.1170273 
#> ... New best solution
#> ... Procrustes: rmse 0.05010316  max resid 0.1680537 
#> Run 135 stress 0.1196313 
#> Run 136 stress 0.1196387 
#> Run 137 stress 0.1191818 
#> Run 138 stress 0.1192874 
#> Run 139 stress 0.1212353 
#> Run 140 stress 0.1179408 
#> Run 141 stress 0.1211888 
#> Run 142 stress 0.1187828 
#> Run 143 stress 0.1187439 
#> Run 144 stress 0.1192359 
#> Run 145 stress 0.1198766 
#> Run 146 stress 0.1178705 
#> Run 147 stress 0.1206463 
#> Run 148 stress 0.1202723 
#> Run 149 stress 0.1191229 
#> Run 150 stress 0.1205023 
#> Run 151 stress 0.119116 
#> Run 152 stress 0.1207249 
#> Run 153 stress 0.1205328 
#> Run 154 stress 0.1188797 
#> Run 155 stress 0.1181536 
#> Run 156 stress 0.1177391 
#> Run 157 stress 0.1192483 
#> Run 158 stress 0.1187447 
#> Run 159 stress 0.1187274 
#> Run 160 stress 0.119789 
#> Run 161 stress 0.117532 
#> Run 162 stress 0.119218 
#> Run 163 stress 0.1187323 
#> Run 164 stress 0.1192804 
#> Run 165 stress 0.1199956 
#> Run 166 stress 0.1197257 
#> Run 167 stress 0.1192248 
#> Run 168 stress 0.1202372 
#> Run 169 stress 0.1183098 
#> Run 170 stress 0.118582 
#> Run 171 stress 0.1205904 
#> Run 172 stress 0.1193964 
#> Run 173 stress 0.1195328 
#> Run 174 stress 0.1196235 
#> Run 175 stress 0.1189398 
#> Run 176 stress 0.1198216 
#> Run 177 stress 0.1193469 
#> Run 178 stress 0.1185882 
#> Run 179 stress 0.1207758 
#> Run 180 stress 0.1186025 
#> Run 181 stress 0.1209859 
#> Run 182 stress 0.1197131 
#> Run 183 stress 0.1188122 
#> Run 184 stress 0.1190777 
#> Run 185 stress 0.1210058 
#> Run 186 stress 0.1186621 
#> Run 187 stress 0.119827 
#> Run 188 stress 0.1184231 
#> Run 189 stress 0.1185472 
#> Run 190 stress 0.1177157 
#> Run 191 stress 0.1186112 
#> Run 192 stress 0.1199314 
#> Run 193 stress 0.1204037 
#> Run 194 stress 0.1190001 
#> Run 195 stress 0.1203588 
#> Run 196 stress 0.1178689 
#> Run 197 stress 0.1205667 
#> Run 198 stress 0.1187872 
#> Run 199 stress 0.1199537 
#> Run 200 stress 0.1181486 
#> Run 201 stress 0.1187974 
#> Run 202 stress 0.1212225 
#> Run 203 stress 0.1188029 
#> Run 204 stress 0.1194458 
#> Run 205 stress 0.1185205 
#> Run 206 stress 0.1178979 
#> Run 207 stress 0.1191918 
#> Run 208 stress 0.1189383 
#> Run 209 stress 0.1184035 
#> Run 210 stress 0.1190313 
#> Run 211 stress 0.1202037 
#> Run 212 stress 0.1211748 
#> Run 213 stress 0.1188042 
#> Run 214 stress 0.1184125 
#> Run 215 stress 0.11905 
#> Run 216 stress 0.1178803 
#> Run 217 stress 0.1191112 
#> Run 218 stress 0.1198689 
#> Run 219 stress 0.1200783 
#> Run 220 stress 0.12028 
#> Run 221 stress 0.1180145 
#> Run 222 stress 0.1179726 
#> Run 223 stress 0.1201824 
#> Run 224 stress 0.119962 
#> Run 225 stress 0.1199863 
#> Run 226 stress 0.1184914 
#> Run 227 stress 0.118089 
#> Run 228 stress 0.119551 
#> Run 229 stress 0.1185101 
#> Run 230 stress 0.1197503 
#> Run 231 stress 0.1190898 
#> Run 232 stress 0.1188015 
#> Run 233 stress 0.1187305 
#> Run 234 stress 0.1199756 
#> Run 235 stress 0.1191176 
#> Run 236 stress 0.1189301 
#> Run 237 stress 0.1178636 
#> Run 238 stress 0.1195764 
#> Run 239 stress 0.1200166 
#> Run 240 stress 0.1203436 
#> Run 241 stress 0.1198609 
#> Run 242 stress 0.1201336 
#> Run 243 stress 0.1195245 
#> Run 244 stress 0.1196085 
#> Run 245 stress 0.1200149 
#> Run 246 stress 0.1186899 
#> Run 247 stress 0.1205283 
#> Run 248 stress 0.1184975 
#> Run 249 stress 0.1196874 
#> Run 250 stress 0.1200743 
#> Run 251 stress 0.1196239 
#> Run 252 stress 0.1221315 
#> Run 253 stress 0.1197399 
#> Run 254 stress 0.1186761 
#> Run 255 stress 0.1198257 
#> Run 256 stress 0.1181677 
#> Run 257 stress 0.1200813 
#> Run 258 stress 0.1188437 
#> Run 259 stress 0.120216 
#> Run 260 stress 0.1191283 
#> Run 261 stress 0.1195599 
#> Run 262 stress 0.1185698 
#> Run 263 stress 0.1198838 
#> Run 264 stress 0.1211468 
#> Run 265 stress 0.1194043 
#> Run 266 stress 0.118099 
#> Run 267 stress 0.1189201 
#> Run 268 stress 0.1194005 
#> Run 269 stress 0.1203483 
#> Run 270 stress 0.1203844 
#> Run 271 stress 0.1188839 
#> Run 272 stress 0.1198304 
#> Run 273 stress 0.1188922 
#> Run 274 stress 0.1182808 
#> Run 275 stress 0.1192537 
#> Run 276 stress 0.1196556 
#> Run 277 stress 0.1188808 
#> Run 278 stress 0.1206397 
#> Run 279 stress 0.1190075 
#> Run 280 stress 0.1191968 
#> Run 281 stress 0.1201328 
#> Run 282 stress 0.1196064 
#> Run 283 stress 0.120566 
#> Run 284 stress 0.1199193 
#> Run 285 stress 0.1193644 
#> Run 286 stress 0.1214491 
#> Run 287 stress 0.1202031 
#> Run 288 stress 0.1205221 
#> Run 289 stress 0.1193598 
#> Run 290 stress 0.1191514 
#> Run 291 stress 0.1193412 
#> Run 292 stress 0.1194808 
#> Run 293 stress 0.1189031 
#> Run 294 stress 0.119073 
#> Run 295 stress 0.1188894 
#> Run 296 stress 0.1196449 
#> Run 297 stress 0.1196764 
#> Run 298 stress 0.1179211 
#> Run 299 stress 0.1209029 
#> Run 300 stress 0.119288 
#> *** Best solution was not repeated -- monoMDS stopping criteria:
#>    300: no. of iterations >= maxit

# plot the graph
vegan::ordisurf((example_NMDS),CToperation_elev_sf$elevation,main="",col="forestgreen", trymax=100) # bubble = 2
#> 
#> Family: gaussian 
#> Link function: identity 
#> 
#> Formula:
#> y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
#> 
#> Estimated degrees of freedom:
#> 5.75  total = 6.75 
#> 
#> REML score: 721.9885
vegan::orditorp(example_NMDS,display="species",col="blue",air=0.1,
   cex=0.5)

We can make a similar plot using gg_ordisurf from the package ggordiplots but also incorporating habitat type.

Code
# ggordiplots::gg_ordisurf()
# To fit a surface with ggordiplots:

 
ordiplot <- gg_ordisurf(ord = example_NMDS, 
                        env.var = CToperation_elev_sf$elevation,
                        var.label = "Elevation",
                        pt.size = 2,
                        groups = CToperation_elev_sf$hab_code,
                        binwidth = 50)

Code

# ggplotly(ordiplot$plot) # see interactive

# # alternative using biodiversityR
# 
# A1.surface <- ordisurf( y=example_NMDS)
# A1.grid <- ordisurfgrid.long(A1.surface)
# # Preparing the plot
# 
# plotgg4 <- ggplot() + 
#     geom_contour_filled(data=A1.grid, 
#                         aes(x=x, y=y, z=z)) +
#     geom_vline(xintercept = c(0), color = "grey70", linetype = 2) +
#     geom_hline(yintercept = c(0), color = "grey70", linetype = 2) +  
#     xlab(axis.long2[1, "label"]) +
#     ylab(axis.long2[2, "label"]) +  
#     scale_x_continuous(sec.axis = dup_axis(labels=NULL, name=NULL)) +
#     scale_y_continuous(sec.axis = dup_axis(labels=NULL, name=NULL)) +
#     geom_point(data=sites.long2, 
#                aes(x=axis1, y=axis2, shape=Management), 
#                colour="red", size=4) +
#     BioR.theme +
#     scale_fill_viridis_d() +
#     labs(fill="A1") +
#     coord_fixed(ratio=1)
# # and seeing the plot.
# 
# plotgg4

The contours connect species in the ordination space that are predicted to have the same elevation.

Rarefaction using iNEXT

Code



out <- iNEXT(incidence_cesar, # The data frame
             q=0,# The type of diversity estimator 
             datatype="incidence_freq",   # The type of analysis
             knots=40,                    # The number of data points 
             se=TRUE,                     # confidence intervals
             conf=0.95,                   # The level of confidence intervals
             nboot=100)                    # The number of bootstraps 

ggiNEXT(out, type=1)

Code
ggiNEXT(out, type=2)

Code
ggiNEXT(out, type=3)

Code

p1 <- ggiNEXT(out, type=1)+ theme_classic() +   #  type 1 = the diversity estimator
        labs(x = "Survey sites", y = "Richness")
  
p2 <- ggiNEXT(out, type=2)+ theme_classic() +    #  type 2 = the survey coverage
        labs(x = "Survey sites")
    
grid.arrange(p1, p2, nrow = 2)

Code
##############
out2 <- iNEXT(incidence_cesar, q=c(0,1,2) ,datatype="incidence_freq" )

ggiNEXT(out2, type=1, facet.var="Order.q", color.var="Assemblage") + theme_classic() 

The iNEXT package is well suited for comparisons of diversity indices through the use of hill numbers - of which the q value = 1 represents the traditional diversity indices: The species richness is q = 0. The Shannon index is (q=1), and Simpson is (q=2). Note Increasing values of q reduces the influence of rare species on our estimate of community diversity.

Package Citation

Code
pkgs <- cite_packages(output = "paragraph", out.dir = ".") #knitr::kable(pkgs)
pkgs

We used R version 4.3.2 (R Core Team 2023) and the following R packages: camtrapR v. 2.3.0 (Niedballa et al. 2016), devtools v. 2.4.5 (Wickham et al. 2022), DT v. 0.32 (Xie, Cheng, and Tan 2024), eks v. 1.0.5 (Duong 2024), elevatr v. 0.99.0 (Hollister et al. 2023), ggforce v. 0.4.2 (Pedersen 2024a), ggordiplots v. 0.4.3 (Quensen, Simpson, and Oksanen 2024), ggvegan v. 0.1.999 (Simpson and Oksanen 2023), gridExtra v. 2.3 (Auguie 2017), iNEXT v. 3.0.1 (Chao et al. 2014; Hsieh, Ma, and Chao 2024), kableExtra v. 1.4.0 (Zhu 2024), knitr v. 1.46 (Xie 2014, 2015, 2024), mapview v. 2.11.2 (Appelhans et al. 2023), MeanRarity v. 0.0.1.5 (Roswell and Dushoff 2023), patchwork v. 1.2.0 (Pedersen 2024b), plotly v. 4.10.4 (Sievert 2020), plyr v. 1.8.9 (Wickham 2011), reshape2 v. 1.4.4 (Wickham 2007), rmarkdown v. 2.27 (Xie, Allaire, and Grolemund 2018; Xie, Dervieux, and Riederer 2020; Allaire et al. 2024), scales v. 1.3.0 (Wickham, Pedersen, and Seidel 2023), sf v. 1.0.15 (Pebesma 2018; Pebesma and Bivand 2023), SpadeR v. 0.1.1 (Chao et al. 2016), tidyverse v. 2.0.0 (Wickham et al. 2019), tmap v. 3.99.9000 (Tennekes 2018), vegan v. 2.6.6.1 (Oksanen et al. 2024).

Sesion info

Session info
#> ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.2 (2023-10-31 ucrt)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Spanish_Colombia.utf8
#>  ctype    Spanish_Colombia.utf8
#>  tz       America/Bogota
#>  date     2024-07-06
#>  pandoc   3.1.11 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  ! package           * version     date (UTC) lib source
#>    abind               1.4-5       2016-07-21 [1] CRAN (R 4.3.1)
#>    base64enc           0.1-3       2015-07-28 [1] CRAN (R 4.3.1)
#>    brew                1.0-10      2023-12-16 [1] CRAN (R 4.3.2)
#>    bslib               0.6.1       2023-11-28 [1] CRAN (R 4.3.2)
#>    cachem              1.0.8       2023-05-01 [1] CRAN (R 4.3.2)
#>    camtrapR          * 2.3.0       2024-02-26 [1] CRAN (R 4.3.3)
#>    cellranger          1.1.0       2016-07-27 [1] CRAN (R 4.3.2)
#>    class               7.3-22      2023-05-03 [2] CRAN (R 4.3.2)
#>    classInt            0.4-10      2023-09-05 [1] CRAN (R 4.3.2)
#>    cli                 3.6.2       2023-12-11 [1] CRAN (R 4.3.2)
#>    cluster             2.1.4       2022-08-22 [2] CRAN (R 4.3.2)
#>    codetools           0.2-19      2023-02-01 [2] CRAN (R 4.3.2)
#>    colorspace          2.1-0       2023-01-23 [1] CRAN (R 4.3.2)
#>    cols4all            0.7         2024-02-20 [1] Github (mtennekes/cols4all@91856c0)
#>    crayon              1.5.2       2022-09-29 [1] CRAN (R 4.3.2)
#>    crosstalk           1.2.1       2023-11-23 [1] CRAN (R 4.3.2)
#>    curl                5.2.0       2023-12-08 [1] CRAN (R 4.3.2)
#>    data.table          1.15.0      2024-01-30 [1] CRAN (R 4.3.2)
#>    DBI                 1.2.2       2024-02-16 [1] CRAN (R 4.3.2)
#>    devtools            2.4.5       2022-10-11 [1] CRAN (R 4.3.2)
#>    dichromat           2.0-0.1     2022-05-02 [1] CRAN (R 4.3.1)
#>    digest              0.6.34      2024-01-11 [1] CRAN (R 4.3.2)
#>    dplyr             * 1.1.4       2023-11-17 [1] CRAN (R 4.3.2)
#>    DT                * 0.32        2024-02-19 [1] CRAN (R 4.3.3)
#>    e1071               1.7-14      2023-12-06 [1] CRAN (R 4.3.2)
#>    eks               * 1.0.5       2024-05-01 [1] CRAN (R 4.3.3)
#>    elevatr           * 0.99.0      2023-09-12 [1] CRAN (R 4.3.2)
#>    ellipsis            0.3.2       2021-04-29 [1] CRAN (R 4.3.2)
#>    evaluate            0.23        2023-11-01 [1] CRAN (R 4.3.2)
#>    fansi               1.0.6       2023-12-08 [1] CRAN (R 4.3.2)
#>    farver              2.1.1       2022-07-06 [1] CRAN (R 4.3.2)
#>    fastmap             1.1.1       2023-02-24 [1] CRAN (R 4.3.2)
#>    forcats           * 1.0.0       2023-01-29 [1] CRAN (R 4.3.2)
#>    fs                  1.6.3       2023-07-20 [1] CRAN (R 4.3.2)
#>    generics            0.1.3       2022-07-05 [1] CRAN (R 4.3.2)
#>    ggforce           * 0.4.2       2024-02-19 [1] CRAN (R 4.3.3)
#>    ggordiplots       * 0.4.3       2024-01-14 [1] CRAN (R 4.3.3)
#>    ggplot2           * 3.5.1       2024-04-23 [1] CRAN (R 4.3.3)
#>    ggrepel             0.9.5       2024-01-10 [1] CRAN (R 4.3.3)
#>    ggvegan           * 0.1.999     2024-06-28 [1] Github (gavinsimpson/ggvegan@058c08c)
#>    glue              * 1.7.0       2024-01-09 [1] CRAN (R 4.3.2)
#>    grateful          * 0.2.4       2023-10-22 [1] CRAN (R 4.3.3)
#>    gridExtra         * 2.3         2017-09-09 [1] CRAN (R 4.3.2)
#>    gtable              0.3.4       2023-08-21 [1] CRAN (R 4.3.2)
#>    hms                 1.1.3       2023-03-21 [1] CRAN (R 4.3.2)
#>    htmltools           0.5.7       2023-11-03 [1] CRAN (R 4.3.2)
#>    htmlwidgets         1.6.4       2023-12-06 [1] CRAN (R 4.3.2)
#>    httpuv              1.6.14      2024-01-26 [1] CRAN (R 4.3.2)
#>    httr                1.4.7       2023-08-15 [1] CRAN (R 4.3.2)
#>    iNEXT             * 3.0.1       2024-03-24 [1] CRAN (R 4.3.3)
#>    isoband             0.2.7       2022-12-20 [1] CRAN (R 4.3.2)
#>    jquerylib           0.1.4       2021-04-26 [1] CRAN (R 4.3.2)
#>    jsonlite            1.8.8       2023-12-04 [1] CRAN (R 4.3.2)
#>    kableExtra        * 1.4.0       2024-01-24 [1] CRAN (R 4.3.3)
#>    KernSmooth          2.23-22     2023-07-10 [2] CRAN (R 4.3.2)
#>    knitr             * 1.46        2024-04-06 [1] CRAN (R 4.3.3)
#>    ks                  1.14.2      2024-01-15 [1] CRAN (R 4.3.3)
#>    labeling            0.4.3       2023-08-29 [1] CRAN (R 4.3.1)
#>    later               1.3.2       2023-12-06 [1] CRAN (R 4.3.2)
#>    lattice           * 0.22-5      2023-10-24 [1] CRAN (R 4.3.2)
#>    lazyeval            0.2.2       2019-03-15 [1] CRAN (R 4.3.2)
#>    leafem              0.2.3       2023-09-17 [1] CRAN (R 4.3.2)
#>    leaflegend          1.2.0       2024-01-10 [1] CRAN (R 4.3.2)
#>    leaflet             2.2.1       2023-11-13 [1] CRAN (R 4.3.2)
#>    leaflet.providers   2.0.0       2023-10-17 [1] CRAN (R 4.3.2)
#>    leafpop             0.1.0       2021-05-22 [1] CRAN (R 4.3.2)
#>    leafsync            0.1.0       2019-03-05 [1] CRAN (R 4.3.2)
#>    lifecycle           1.0.4       2023-11-07 [1] CRAN (R 4.3.2)
#>    lubridate         * 1.9.3       2023-09-27 [1] CRAN (R 4.3.2)
#>    lwgeom              0.2-13      2023-05-22 [1] CRAN (R 4.3.2)
#>    magrittr            2.0.3       2022-03-30 [1] CRAN (R 4.3.2)
#>    maplegend           0.1.0       2023-10-18 [1] CRAN (R 4.3.3)
#>    mapsf               0.10.1      2024-05-06 [1] CRAN (R 4.3.3)
#>    mapview           * 2.11.2      2023-10-13 [1] CRAN (R 4.3.2)
#>    MASS                7.3-60      2023-05-04 [2] CRAN (R 4.3.2)
#>    Matrix              1.6-1.1     2023-09-18 [2] CRAN (R 4.3.2)
#>    mclust              6.1         2024-02-23 [1] CRAN (R 4.3.3)
#>    MeanRarity        * 0.0.1.0005  2024-07-03 [1] Github (mikeroswell/MeanRarity@a8b518d)
#>    memoise             2.0.1       2021-11-26 [1] CRAN (R 4.3.2)
#>    mgcv                1.9-1       2023-12-21 [1] CRAN (R 4.3.3)
#>    mime                0.12        2021-09-28 [1] CRAN (R 4.3.1)
#>    miniUI              0.1.1.1     2018-05-18 [1] CRAN (R 4.3.2)
#>    munsell             0.5.0       2018-06-12 [1] CRAN (R 4.3.2)
#>    mvtnorm             1.2-4       2023-11-27 [1] CRAN (R 4.3.3)
#>    nlme                3.1-163     2023-08-09 [2] CRAN (R 4.3.2)
#>    patchwork         * 1.2.0       2024-01-08 [1] CRAN (R 4.3.3)
#>    permute           * 0.9-7       2022-01-27 [1] CRAN (R 4.3.3)
#>    pillar              1.9.0       2023-03-22 [1] CRAN (R 4.3.2)
#>    pkgbuild            1.4.4       2024-03-17 [1] CRAN (R 4.3.3)
#>    pkgconfig           2.0.3       2019-09-22 [1] CRAN (R 4.3.2)
#>    pkgload             1.3.4       2024-01-16 [1] CRAN (R 4.3.2)
#>    plotly            * 4.10.4      2024-01-13 [1] CRAN (R 4.3.3)
#>    plyr              * 1.8.9       2023-10-02 [1] CRAN (R 4.3.2)
#>    png                 0.1-8       2022-11-29 [1] CRAN (R 4.3.1)
#>    polyclip            1.10-6      2023-09-27 [1] CRAN (R 4.3.1)
#>    pracma              2.4.4       2023-11-10 [1] CRAN (R 4.3.3)
#>    prettyunits         1.2.0       2023-09-24 [1] CRAN (R 4.3.2)
#>    profvis             0.3.8       2023-05-02 [1] CRAN (R 4.3.2)
#>    progress            1.2.3       2023-12-06 [1] CRAN (R 4.3.3)
#>    progressr           0.14.0      2023-08-10 [1] CRAN (R 4.3.2)
#>    promises            1.2.1       2023-08-10 [1] CRAN (R 4.3.2)
#>    proxy               0.4-27      2022-06-09 [1] CRAN (R 4.3.2)
#>    purrr             * 1.0.2       2023-08-10 [1] CRAN (R 4.3.2)
#>    R6                  2.5.1       2021-08-19 [1] CRAN (R 4.3.2)
#>    raster              3.6-26      2023-10-14 [1] CRAN (R 4.3.2)
#>    rbibutils           2.2.16      2023-10-25 [1] CRAN (R 4.3.3)
#>    RColorBrewer        1.1-3       2022-04-03 [1] CRAN (R 4.3.1)
#>    Rcpp                1.0.12      2024-01-09 [1] CRAN (R 4.3.2)
#>    RcppNumerical       0.6-0       2023-09-06 [1] CRAN (R 4.3.3)
#>  D RcppParallel        5.1.7       2023-02-27 [1] CRAN (R 4.3.2)
#>    Rdpack              2.6         2023-11-08 [1] CRAN (R 4.3.3)
#>    readr             * 2.1.5       2024-01-10 [1] CRAN (R 4.3.2)
#>    readxl            * 1.4.3       2023-07-06 [1] CRAN (R 4.3.2)
#>    remotes             2.5.0       2024-03-17 [1] CRAN (R 4.3.3)
#>    renv                1.0.7       2024-04-11 [1] CRAN (R 4.3.3)
#>    reshape2          * 1.4.4       2020-04-09 [1] CRAN (R 4.3.3)
#>    rlang               1.1.3       2024-01-10 [1] CRAN (R 4.3.2)
#>    rmarkdown           2.27        2024-05-17 [1] CRAN (R 4.3.3)
#>    rstudioapi          0.16.0      2024-03-24 [1] CRAN (R 4.3.3)
#>    s2                  1.1.6       2023-12-19 [1] CRAN (R 4.3.2)
#>    sass                0.4.8       2023-12-06 [1] CRAN (R 4.3.2)
#>    satellite           1.0.5       2024-02-10 [1] CRAN (R 4.3.2)
#>    scales            * 1.3.0       2023-11-28 [1] CRAN (R 4.3.3)
#>    secr                4.6.6       2024-02-29 [1] CRAN (R 4.3.3)
#>    sessioninfo         1.2.2       2021-12-06 [1] CRAN (R 4.3.2)
#>    sf                * 1.0-15      2023-12-18 [1] CRAN (R 4.3.2)
#>    shiny               1.8.0       2023-11-17 [1] CRAN (R 4.3.2)
#>    slippymath          0.3.1       2019-06-28 [1] CRAN (R 4.3.2)
#>    sp                  2.1-3       2024-01-30 [1] CRAN (R 4.3.2)
#>    SpadeR            * 0.1.1       2016-09-06 [1] CRAN (R 4.3.1)
#>    stars               0.6-4       2023-09-11 [1] CRAN (R 4.3.2)
#>    stringi             1.8.3       2023-12-11 [1] CRAN (R 4.3.2)
#>    stringr           * 1.5.1       2023-11-14 [1] CRAN (R 4.3.2)
#>    svglite             2.1.3       2023-12-08 [1] CRAN (R 4.3.2)
#>    systemfonts         1.0.5       2023-10-09 [1] CRAN (R 4.3.2)
#>    terra               1.7-71      2024-01-31 [1] CRAN (R 4.3.2)
#>    tibble            * 3.2.1       2023-03-20 [1] CRAN (R 4.3.2)
#>    tidyr             * 1.3.1       2024-01-24 [1] CRAN (R 4.3.2)
#>    tidyselect          1.2.1       2024-03-11 [1] CRAN (R 4.3.3)
#>    tidyverse         * 2.0.0       2023-02-22 [1] CRAN (R 4.3.2)
#>    timechange          0.3.0       2024-01-18 [1] CRAN (R 4.3.2)
#>    tmap              * 3.99.9000   2024-02-22 [1] Github (r-tmap/tmap@afbf4e8)
#>    tmaptools           3.1-1       2024-02-20 [1] Github (r-tmap/tmaptools@0c8b0b1)
#>    tweenr              2.0.3       2024-02-26 [1] CRAN (R 4.3.3)
#>    tzdb                0.4.0       2023-05-12 [1] CRAN (R 4.3.2)
#>    units               0.8-5       2023-11-28 [1] CRAN (R 4.3.2)
#>    urlchecker          1.0.1       2021-11-30 [1] CRAN (R 4.3.2)
#>    usethis             2.2.3       2024-02-19 [1] CRAN (R 4.3.2)
#>    utf8                1.2.4       2023-10-22 [1] CRAN (R 4.3.2)
#>    uuid                1.2-0       2024-01-14 [1] CRAN (R 4.3.2)
#>    vctrs               0.6.5       2023-12-01 [1] CRAN (R 4.3.2)
#>    vegan             * 2.6-6.1     2024-05-21 [1] CRAN (R 4.3.3)
#>    viridisLite         0.4.2       2023-05-02 [1] CRAN (R 4.3.2)
#>    widgetframe         0.3.1       2017-12-20 [1] CRAN (R 4.3.2)
#>    withr               3.0.0       2024-01-16 [1] CRAN (R 4.3.2)
#>    wk                  0.9.1       2023-11-29 [1] CRAN (R 4.3.2)
#>    xfun                0.44        2024-05-15 [1] CRAN (R 4.3.3)
#>    XML                 3.99-0.16.1 2024-01-22 [1] CRAN (R 4.3.2)
#>    xml2                1.3.6       2023-12-04 [1] CRAN (R 4.3.2)
#>    xtable              1.8-4       2019-04-21 [1] CRAN (R 4.3.2)
#>    yaml                2.3.8       2023-12-11 [1] CRAN (R 4.3.2)
#> 
#>  [1] C:/Users/usuario/AppData/Local/R/win-library/4.3
#>  [2] C:/Program Files/R/R-4.3.2/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

References

Allaire, JJ, Yihui Xie, Christophe Dervieux, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, et al. 2024. rmarkdown: Dynamic Documents for r. https://github.com/rstudio/rmarkdown.
Appelhans, Tim, Florian Detsch, Christoph Reudenbach, and Stefan Woellauer. 2023. mapview: Interactive Viewing of Spatial Data in r. https://CRAN.R-project.org/package=mapview.
Auguie, Baptiste. 2017. gridExtra: Miscellaneous Functions for Grid Graphics. https://CRAN.R-project.org/package=gridExtra.
Chao, Anne, Nicholas J. Gotelli, T. C. Hsieh, Elizabeth L. Sander, K. H. Ma, Robert K. Colwell, and Aaron M. Ellison. 2014. “Rarefaction and Extrapolation with Hill Numbers: A Framework for Sampling and Estimation in Species Diversity Studies.” Ecological Monographs 84: 45–67.
Chao, Anne, K. H. Ma, T. C. Hsieh, and Chun-Huo Chiu. 2016. SpadeR: Species-Richness Prediction and Diversity Estimation with r. https://CRAN.R-project.org/package=SpadeR.
Duong, Tarn. 2024. eks: Tidy and Geospatial Kernel Smoothing. https://CRAN.R-project.org/package=eks.
Hollister, Jeffrey, Tarak Shah, Jakub Nowosad, Alec L. Robitaille, Marcus W. Beck, and Mike Johnson. 2023. elevatr: Access Elevation Data from Various APIs. https://doi.org/10.5281/zenodo.8335450.
Hsieh, T. C., K. H. Ma, and Anne Chao. 2024. iNEXT: Interpolation and Extrapolation for Species Diversity. http://chao.stat.nthu.edu.tw/wordpress/software_download/.
Niedballa, Jürgen, Rahel Sollmann, Alexandre Courtiol, and Andreas Wilting. 2016. camtrapR: An r Package for Efficient Camera Trap Data Management.” Methods in Ecology and Evolution 7 (12): 1457–62. https://doi.org/10.1111/2041-210X.12600.
Oksanen, Jari, Gavin L. Simpson, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O’Hara, et al. 2024. vegan: Community Ecology Package. https://CRAN.R-project.org/package=vegan.
Pebesma, Edzer. 2018. Simple Features for R: Standardized Support for Spatial Vector Data.” The R Journal 10 (1): 439–46. https://doi.org/10.32614/RJ-2018-009.
Pebesma, Edzer, and Roger Bivand. 2023. Spatial Data Science: With applications in R. Chapman and Hall/CRC. https://doi.org/10.1201/9780429459016.
Pedersen, Thomas Lin. 2024a. ggforce: Accelerating ggplot2. https://CRAN.R-project.org/package=ggforce.
———. 2024b. patchwork: The Composer of Plots. https://CRAN.R-project.org/package=patchwork.
Quensen, John, Gavin Simpson, and Jari Oksanen. 2024. ggordiplots: Make ggplot2 Versions of Vegan’s Ordiplots. https://CRAN.R-project.org/package=ggordiplots.
R Core Team. 2023. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Roswell, Michael, and Joanathan Dushoff. 2023. MeanRarity: Hill Diversity Estimation and Visualization. https://github.com/mikeroswell/MeanRarity.
Sievert, Carson. 2020. Interactive Web-Based Data Visualization with r, Plotly, and Shiny. Chapman; Hall/CRC. https://plotly-r.com.
Simpson, Gavin L., and Jari Oksanen. 2023. ggvegan: ggplot2 Plots for the vegan Package.
Tennekes, Martijn. 2018. tmap: Thematic Maps in R.” Journal of Statistical Software 84 (6): 1–39. https://doi.org/10.18637/jss.v084.i06.
Wickham, Hadley. 2007. “Reshaping Data with the reshape Package.” Journal of Statistical Software 21 (12): 1–20. http://www.jstatsoft.org/v21/i12/.
———. 2011. “The Split-Apply-Combine Strategy for Data Analysis.” Journal of Statistical Software 40 (1): 1–29. https://www.jstatsoft.org/v40/i01/.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Wickham, Hadley, Jim Hester, Winston Chang, and Jennifer Bryan. 2022. devtools: Tools to Make Developing r Packages Easier. https://CRAN.R-project.org/package=devtools.
Wickham, Hadley, Thomas Lin Pedersen, and Dana Seidel. 2023. scales: Scale Functions for Visualization. https://CRAN.R-project.org/package=scales.
Xie, Yihui. 2014. knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2024. knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.
Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.
Xie, Yihui, Joe Cheng, and Xianying Tan. 2024. DT: A Wrapper of the JavaScript Library DataTables. https://CRAN.R-project.org/package=DT.
Xie, Yihui, Christophe Dervieux, and Emily Riederer. 2020. R Markdown Cookbook. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown-cookbook.
Zhu, Hao. 2024. kableExtra: Construct Complex Table with kable and Pipe Syntax. https://CRAN.R-project.org/package=kableExtra.

Citation

BibTeX citation:
@online{j._lizcano2024,
  author = {J. Lizcano, Diego},
  title = {Species Diversity},
  date = {2024-06-25},
  url = {https://dlizcano.github.io/cametrapcesar/posts/2024-06-25-species-diversity/},
  langid = {en}
}
For attribution, please cite this work as:
J. Lizcano, Diego. 2024. “Species Diversity.” June 25, 2024. https://dlizcano.github.io/cametrapcesar/posts/2024-06-25-species-diversity/.