This page is restricted.
Please enter the access password.
An annotated catalogue of the community R packages used in my research and teaching, organised by theme: what each package does, the functions I rely on, and the reference to cite.
Complete workflow for multidimensional functional diversity: Gower distances on mixed traits, quality assessment of functional spaces, and alpha/beta indices (FRic, FDiv, FEve, FDis, FOri, FSpe) plus Hill-number based indices.
funct.dist()quality.fspaces()alpha.fd.multidim()beta.fd.multidim()alpha.fd.hill()Magneville C. et al. (2022) mFD: an R package to compute and illustrate the multiple facets of functional diversity. Ecography 2022: e05904.
FD
The historical reference for distance-based functional diversity indices from multiple traits (FRic, FEve, FDiv, FDis, RaoQ) and community-weighted means. Still the fastest route for the Gower distance on mixed trait tables.
dbFD()gowdis()functcomp()Laliberté E. & Legendre P. (2010) A distance-based framework for measuring functional diversity from multiple traits. Ecology 91: 299–305.
TPD
Trait Probability Density framework: functional diversity as probability distributions in trait space, which integrates intraspecific variability and scales from individuals to species and communities (richness, evenness, divergence, dissimilarity, redundancy).
TPDs()TPDc()REND()dissim()redundancy()Carmona C.P., de Bello F., Mason N.W.H. & Lepš J. (2016) Traits without borders: integrating functional diversity across scales. Trends in Ecology & Evolution 31: 382–394. — Carmona C.P. et al. (2019) Ecology 100: e02876.
funspace
Builds, analyses and plots functional trait spaces from a PCA or raw traits using kernel density estimation; includes null models for occupation of the space and GAM-based mapping of a response variable onto the space.
funspace()plot.funspace()funspaceNull()funspaceGAM()Carmona C.P., Pavanetto N. & Puglielli G. (2024) funspace: an R package to build, analyse and plot functional trait spaces. Diversity and Distributions 30: e13820.
hypervolume
n-dimensional hypervolumes (Gaussian KDE, box, SVM) to describe niche or trait volumes, with set operations (union, intersection, unique fractions) and overlap statistics between groups.
hypervolume_gaussian()hypervolume_set()hypervolume_overlap_statistics()get_volume()Blonder B. et al. (2014) The n-dimensional hypervolume. Global Ecology and Biogeography 23: 595–609. — Blonder B. et al. (2018) Methods in Ecology and Evolution 9: 305–319.
funrar
Functional rarity indices at the species and community level: distinctiveness and uniqueness (trait-based), scarcity and restrictedness (abundance/occupancy-based).
distinctiveness()uniqueness()scarcity()restrictedness()Grenié M., Denelle P., Tucker C.M., Munoz F. & Violle C. (2017) funrar: An R package to characterize functional rarity. Diversity and Distributions 23: 1365–1371.
geometry
Interface to Qhull: convex hulls and their volume in n dimensions, Delaunay triangulation and point-in-hull tests — the building blocks of convex-hull based functional richness.
convhulln()inhulln()delaunayn()Habel K., Grasman R., Gramacy R.B., Mozharovskyi P. & Sterratt D.C. geometry: Mesh generation and surface tessellation. R package (CRAN).
traitdataform
Harmonises heterogeneous trait datasets into the Ecological Trait-data Standard (ETS): long-format trait tables, taxon-name matching against GBIF, unit and trait-name standardisation.
as.traitdata()standardize_taxa()standardize_traits()Schneider F.D. et al. (2019) Towards an ecological trait-data standard. Methods in Ecology and Evolution 10: 2006–2019.
vegan
The standard toolbox for community ecology: dissimilarity matrices, unconstrained and constrained ordination (NMDS, PCoA, RDA, CCA), permutation tests (PERMANOVA, Mantel), diversity indices and rarefaction.
vegdist()metaMDS()rda()cca()adonis2()diversity()specaccum()Oksanen J. et al. vegan: Community Ecology Package. R package (CRAN).
ade4
Multivariate analyses built on the duality diagram: PCA, PCoA, correspondence and mixed-data analyses, co-inertia and RLQ-type coupling of trait, environment and species tables.
dudi.pca()dudi.pco()dudi.mix()coinertia()mantel.rtest()Dray S. & Dufour A.-B. (2007) The ade4 package: implementing the duality diagram for ecologists. Journal of Statistical Software 22(4): 1–20.
ape
Reading, manipulating and plotting phylogenetic trees; patristic distances, tree pruning and principal coordinates analysis — the base layer for phylogenetic diversity and comparative analyses.
read.tree()drop.tip()cophenetic.phylo()pcoa()plot.phylo()Paradis E. & Schliep K. (2019) ape 5.0: an environment for modern phylogenetics and evolutionary analyses in R. Bioinformatics 35: 526–528.
picante
Community phylogenetics: Faith's PD, mean pairwise and nearest-taxon distances with standardised effect sizes under null models, and phylogenetic signal of traits.
pd()mpd()mntd()ses.mpd()phylosignal()Kembel S.W. et al. (2010) Picante: R tools for integrating phylogenies and ecology. Bioinformatics 26: 1463–1464.
geomorph
Geometric morphometrics of landmark data: generalised Procrustes superimposition, shape-space PCA, and Procrustes ANOVA / linear models on shape.
gpagen()gm.prcomp()procD.lm()Adams D.C. & Otárola-Castillo E. (2013) geomorph: an R package for the collection and analysis of geometric morphometric shape data. Methods in Ecology and Evolution 4: 393–399.
paran
Horn's parallel analysis to decide how many principal components (or factors) to retain, by comparing observed eigenvalues to those of random data.
paran()Dinno A. paran: Horn's test of principal components/factors. R package (CRAN).
irr
Inter-rater reliability and agreement: intraclass correlation coefficients and kappa statistics, used to quantify measurement repeatability of morphological traits between observers.
icc()kappa2()kappam.fleiss()Gamer M., Lemon J. & Fellows Singh I. irr: Various coefficients of interrater reliability and agreement. R package (CRAN).
missForest
Non-parametric imputation of mixed-type data with random forests; returns out-of-bag error estimates (NRMSE, PFC) to assess imputation quality. Works well on trait tables with phylogenetic eigenvectors as predictors.
missForest()Stekhoven D.J. & Bühlmann P. (2012) MissForest — non-parametric missing value imputation for mixed-type data. Bioinformatics 28: 112–118.
mice
Multiple imputation by chained equations: generates several completed datasets, so that downstream models can be fitted on each and pooled to propagate imputation uncertainty.
mice()complete()with()pool()van Buuren S. & Groothuis-Oudshoorn K. (2011) mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software 45(3): 1–67.
lme4
Linear and generalised linear mixed-effects models with crossed or nested random effects; the default for hierarchical designs (sites within basins, species within genera).
lmer()glmer()ranef()Bates D., Mächler M., Bolker B. & Walker S. (2015) Fitting linear mixed-effects models using lme4. Journal of Statistical Software 67(1): 1–48.
nlme
Linear and non-linear mixed models with explicit variance and correlation structures (spatial, temporal, phylogenetic), e.g. generalised least squares with a correlation matrix.
lme()gls()corSpatial()varIdent()Pinheiro J., Bates D. & R Core Team. nlme: Linear and nonlinear mixed effects models. R package (CRAN).
glmmTMB
Fast GLMMs with a wide range of families (beta, negative binomial, Tweedie, ordinal) and zero-inflation or dispersion sub-models — useful for proportions and overdispersed counts.
glmmTMB()Brooks M.E. et al. (2017) glmmTMB balances speed and flexibility among packages for zero-inflated generalized linear mixed modeling. The R Journal 9(2): 378–400.
mgcv
Generalised additive (mixed) models with automatic smoothness selection; tensor-product and spatial smooths for non-linear responses along environmental or temporal gradients.
gam()bam()s()te()Wood S.N. (2017) Generalized Additive Models: An Introduction with R, 2nd ed. Chapman & Hall/CRC.
DHARMa
Simulation-based scaled residuals for (G)LM(M)s, giving interpretable QQ and residual plots and tests for overdispersion, zero-inflation and spatial/temporal autocorrelation.
simulateResiduals()testDispersion()testZeroInflation()Hartig F. DHARMa: residual diagnostics for hierarchical (multi-level/mixed) regression models. R package (CRAN).
MuMIn
Multi-model inference: all-subsets model selection, information-criterion ranking, model averaging and marginal/conditional R² for mixed models.
dredge()model.avg()r.squaredGLMM()Bartoń K. MuMIn: Multi-model inference. R package (CRAN).
performance
Unified assessment of model quality (R², ICC, RMSE), assumption checks (collinearity, heteroscedasticity, outliers) and side-by-side comparison of competing models.
r2()check_model()check_collinearity()compare_performance()Lüdecke D. et al. (2021) performance: An R package for assessment, comparison and testing of statistical models. Journal of Open Source Software 6(60): 3139.
sf
Simple-features standard for vector data: reading shapefiles/GeoPackages, reprojection, geometric predicates and operations (intersection, buffers, joins) in a tidy data-frame workflow.
st_read()st_transform()st_intersects()st_join()st_area()Pebesma E. (2018) Simple features for R: standardized support for spatial vector data. The R Journal 10(1): 439–446.
terra
Raster (and vector) data handling, successor of raster: fast reading of large grids, cropping/masking, zonal statistics and extraction of environmental values at points or polygons.
rast()extract()crop()mask()zonal()Hijmans R.J. terra: Spatial data analysis. R package (CRAN).
dggridR
Discrete global grid systems: equal-area hexagonal grids at chosen resolutions, assignment of coordinates to cells, and cell polygons for mapping — avoids the area bias of lat/long grids in global analyses.
dgconstruct()dgGEO_to_SEQNUM()dgcellstogrid()Barnes R. dggridR: Discrete global grids. R package (CRAN).
rnaturalearth
Natural Earth base layers (countries, coastlines, rivers, lakes) as sf objects, for background maps in publication figures.
ne_countries()ne_coastline()ne_download()Massicotte P. & South A. rnaturalearth: World map data from Natural Earth. R package (CRAN).
rredlist
Client for the IUCN Red List API: retrieves threat categories, assessments, threats and habitats per species (requires a personal API token; functions follow the API v4 since version 1.0).
rl_species()rl_assessment()rl_threats()Chamberlain S. & Gearty W. rredlist: IUCN Red List client. R package (CRAN).
taxize
Taxonomic name resolution across databases (GBIF, ITIS, NCBI, WoRMS…): classification, synonyms and identifiers, used to harmonise species lists before merging trait, occurrence and phylogenetic data.
classification()synonyms()get_gbifid()Chamberlain S.A. & Szöcs E. (2013) taxize: taxonomic search and retrieval in R. F1000Research 2: 191.
rfishbase
Programmatic access to FishBase (and SeaLifeBase) tables: species, ecology, morphology, diet and distribution, plus validation of scientific names against the current FishBase taxonomy.
species()ecology()validate_names()fb_tbl()Boettiger C., Lang D.T. & Wainwright P.C. (2012) rfishbase: exploring, manipulating and visualizing FishBase data from R. Journal of Fish Biology 81: 2030–2039.
Meta-package loading dplyr, tidyr, readr, purrr, tibble, stringr and ggplot2: a consistent grammar for importing, reshaping, grouping and summarising data.
mutate()group_by()summarise()pivot_longer()map()Wickham H. et al. (2019) Welcome to the tidyverse. Journal of Open Source Software 4(43): 1686.
data.table
High-performance alternative to data frames for large tables (millions of occurrence records): very fast reading, keyed joins and by-group aggregation with a compact syntax.
fread()fwrite()setkey()DT[i, j, by]Barrett T., Dowle M., Srinivasan A. et al. data.table: Extension of data.frame. R package (CRAN).
reshape2
Wide ↔ long reshaping of matrices and data frames (melt / dcast); superseded by tidyr for data frames but still convenient for distance and site × species matrices.
melt()dcast()acast()Wickham H. (2007) Reshaping data with the reshape package. Journal of Statistical Software 21(12): 1–20.
Reading and writing Excel workbooks without Java: readxl for fast import of sheets, openxlsx for multi-sheet exports with formatting (supplementary tables, data shared with collaborators).
read_excel()read.xlsx()write.xlsx()Schauberger P. & Walker A. openxlsx — Wickham H. & Bryan J. readxl. R packages (CRAN).
pbapply
Drop-in replacements for the apply family with a progress bar, including parallel execution via cl = — handy for null models and bootstraps run thousands of times.
pblapply()pbsapply()pbreplicate()Sólymos P. & Zawadzki Z. pbapply: Adding progress bar to '*apply' functions. R package (CRAN).
Project-level package libraries and a renv.lock file recording exact package versions, so an analysis can be restored identically on another machine or years later (used in all my GitHub repositories).
renv::init()renv::snapshot()renv::restore()Ushey K. & Wickham H. renv: Project environments. R package (CRAN).
ggplot2
Grammar-of-graphics plotting system: layered geoms, scales, facets and themes; the backbone of every figure in my papers and courses.
ggplot()geom_*()facet_wrap()theme()Wickham H. (2016) ggplot2: Elegant Graphics for Data Analysis, 2nd ed. Springer.
patchwork
Composes several ggplots into multi-panel figures with arithmetic operators (p1 + p2 / p3), shared legends and automatic panel tags.
plot_layout()plot_annotation()wrap_plots()Pedersen T.L. patchwork: The composer of plots. R package (CRAN).
ggrepel
Text and label geoms that repel each other and the data points, so species names in a trait space or PCA biplot remain readable.
geom_text_repel()geom_label_repel()Slowikowski K. ggrepel: Automatically position non-overlapping text labels with 'ggplot2'. R package (CRAN).
ggforce
Extra geoms for ggplot2: convex hulls and ellipses around groups with labels, zoomed facets, sina plots — used to outline taxonomic groups in functional spaces.
geom_mark_hull()geom_mark_ellipse()facet_zoom()geom_sina()Pedersen T.L. ggforce: Accelerating 'ggplot2'. R package (CRAN).
corrplot
Graphical display of correlation matrices with hierarchical reordering and significance marks — a first look at trait redundancy before building a functional space.
corrplot()cor.mtest()Wei T. & Simko V. corrplot: Visualization of a correlation matrix. R package (CRAN).
GGally
ggplot2 extensions for pairwise plots (scatterplot matrices with densities and correlations by group), coefficient plots and network plots.
ggpairs()ggcorr()Schloerke B. et al. GGally: Extension to 'ggplot2'. R package (CRAN).
Installs only the packages that are missing, then loads them all. Package versions used in each project are pinned in its renv.lock.
pkgs <- c(
# functional diversity & trait spaces
"mFD", "FD", "TPD", "funspace", "hypervolume", "funrar", "geometry", "traitdataform",
# community ecology, ordination & phylogenetics
"vegan", "ade4", "ape", "picante", "geomorph", "paran", "irr",
# missing data
"missForest", "mice",
# statistical modelling
"lme4", "nlme", "glmmTMB", "mgcv", "DHARMa", "MuMIn", "performance",
# spatial
"sf", "terra", "dggridR", "rnaturalearth",
# data access & taxonomy
"rredlist", "taxize", "rfishbase",
# wrangling & reproducibility
"tidyverse", "data.table", "reshape2", "openxlsx", "readxl", "pbapply", "renv",
# visualisation
"ggplot2", "patchwork", "ggrepel", "ggforce", "corrplot", "GGally"
)
missing <- pkgs[!pkgs %in% rownames(installed.packages())]
if (length(missing)) install.packages(missing, dependencies = TRUE)
invisible(lapply(pkgs, library, character.only = TRUE))