| Type: | Package |
| Title: | Streamlining Functional Biogeography Analyses |
| Version: | 0.0.1 |
| Description: | Helps users with analyses in functional biogeography by loading and combining data, computing trait coverage, as well as computing functional diversity indices, drawing maps, correlating them with the environment, and upscaling assemblages. |
| URL: | https://frbcesab.github.io/funbiogeo/, https://github.com/frbcesab/funbiogeo |
| BugReports: | https://github.com/frbcesab/funbiogeo/issues |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| Encoding: | UTF-8 |
| LazyData: | true |
| Depends: | R (≥ 3.5.0) |
| Imports: | ggplot2 (≥ 3.4.0), grid, rlang, rnaturalearth, scales, sf, stats, terra, tidyr, tidyselect, tools, utils, xfun |
| Suggests: | dplyr, fs, fundiversity, ggridges, knitr, mFD, mockery, patchwork, rmarkdown, rstudioapi, testthat (≥ 3.0.0), vdiffr, withr |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-20 10:22:19 UTC; nicolas |
| Author: | Nicolas Casajus |
| Maintainer: | Nicolas Casajus <nicolas.casajus@fondationbiodiversite.fr> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-29 16:40:19 UTC |
funbiogeo: Streamlining Functional Biogeography Analyses
Description
Helps users with analyses in functional biogeography by loading and combining data, computing trait coverage, as well as computing functional diversity indices, drawing maps, correlating them with the environment, and upscaling assemblages.
Author(s)
Maintainer: Nicolas Casajus nicolas.casajus@fondationbiodiversite.fr (ORCID) [copyright holder]
Authors:
Nicolas Casajus nicolas.casajus@fondationbiodiversite.fr (ORCID) [copyright holder]
Matthias Grenié matthias.grenie@univ-grenoble-alpes.fr (ORCID)
See Also
Useful links:
Report bugs at https://github.com/frbcesab/funbiogeo/issues
Aggregate Site Data Along Coarser Spatial Grid
Description
This function helps aggregating site data along a coarser grid. The idea is that you have any type of data at the site scale (diversity metrics, environmental data, etc.) but you would like to work on it at a coarser scale, or you want to visualize it at that scale. This function helps you do exactly that.
Usage
fb_aggregate_site_data(site_locations, site_data, agg_geom, fun = mean, ...)
Arguments
site_locations |
a |
site_data |
a |
agg_geom |
a |
fun |
the function used to aggregate point values when there are
multiple points in one cell. Default is |
... |
additional argument(s) passed to the provided function |
Details
The agg_geom object will condition the type of object output by the
function. It can be of any sort of a SpatRaster or a sf object. Depending
on the need, it could be a regular square grid or hexagonal grid; it could
also be irregular polygons like biomes or ecoregions, or points, and even
lines (such as when aggregating across transects or trajectories).
Value
An object of the same type as the agg_geom input with as many
layers (if SpatRaster) or columns (if sf) as columns provided in the
input site_data.
Examples
library("sf")
## Raster grid
tavg <- system.file(
"extdata", "annual_mean_temp.tif", package = "funbiogeo"
)
tavg <- terra::rast(tavg)
# Rasterize 3 first species counts
fb_aggregate_site_data(
head(woodiv_locations), woodiv_site_species[, 1:4], tavg, fun = sum
)
## Irregular polygons
countries <- readRDS(system.file(
"extdata", "countries_sf.rds", package = "funbiogeo"
))
# Aggregate occurrence per country
fb_aggregate_site_data(
head(woodiv_locations, n = 20), woodiv_site_species[, 1:4], countries,
fun = sum
)
Count Number of Sites Occupied by Species
Description
This function computes the number and proportion of sites occupied by each species (distribution value higher than 0 and non-NA).
Usage
fb_count_sites_by_species(site_species)
Arguments
site_species |
a |
Value
A three-column data.frame with:
-
species: the name of the species; -
n_sites: the number of sites where the species is present; -
coverage: the percentage of sites where the species is present.
Examples
site_coverage_by_species <- fb_count_sites_by_species(woodiv_site_species)
head(site_coverage_by_species)
Count Number of Species per Site
Description
This function computes for each site the number and proportion of species present (distribution value higher than 0 and non-NA) compared to all species provided. For example, a site could contain only 20% of all species provided.
Usage
fb_count_species_by_site(site_species)
Arguments
site_species |
a |
Value
A three-column data.frame with:
-
site: the name of the site; -
n_species: the number of present species; -
coverage: the percentage of present species.
Examples
species_coverage_by_site <- fb_count_species_by_site(woodiv_site_species)
head(species_coverage_by_site)
Count Number of Species for Each Trait
Description
This function computes, for each trait, the number and proportion of species
without missing trait value (NA).
Usage
fb_count_species_by_trait(species_traits)
Arguments
species_traits |
a |
Value
A three-column data.frame with:
-
trait: the name of the trait; -
n_species: the number of species with non-missing value for the trait; -
coverage: the percentage of species with non-missing value for the trait.
Examples
species_coverage_by_trait <- fb_count_species_by_trait(woodiv_traits)
head(species_coverage_by_trait)
Compute Number of Known Trait(s) per Species
Description
For each species, this function computes the number and proportion of traits
without NA (missing trait values).
Usage
fb_count_traits_by_species(species_traits)
Arguments
species_traits |
a |
Value
A three-column data.frame with:
-
species: the name of the species; -
n_traits: the number of traits with non-missing value for the species; -
coverage: the percentage of traits with non-missing value for the species.
Examples
trait_coverage_by_species <- fb_count_traits_by_species(woodiv_traits)
head(trait_coverage_by_species)
Compute community-weighted means (CWM) of trait values
Description
This function returns the community-weighted mean of provided trait values.
It only works with quantitative traits and will warn you otherwise.
It will remove species that either have NA values in the site_species
input or NA values as their trait in the provided trait object.
Usage
fb_cwm(site_species, species_traits)
Arguments
site_species |
a |
species_traits |
a |
Details
The community-weighted mean is a site-based trait mean weighted by the abundance of the species. It can be written with the following equation:
\text{CWM}_k = \sum_{i = 1}^S p_{ik} \times t_{ik}
with \text{CWM}_k the CWM of site k, p_{ik} the relative
abundance of species i in site k, and t_{ik} the trait of
species i in site k.
Value
A data.frame with sites in rows and the following variables:
-
site, the site label, -
trait, the trait label as provided inspecies_traits, and
cwm, the community-weighted means of quantitative traits values.
Examples
site_cwm <- fb_cwm(head(woodiv_site_species), woodiv_traits)
head(site_cwm)
Filter sites with a given species coverage threshold
Description
Selects sites (rows) for which the proportion of species present (distribution value higher than 0 and non-NA) is higher than the user-defined threshold.
Usage
fb_filter_sites_by_species_coverage(
site_species,
threshold_species_proportion = 0
)
Arguments
site_species |
a |
threshold_species_proportion |
a numeric of length 1 between 0 and 1. The threshold of species coverage under which to exclude the sites. |
Value
A subset of site_species with sites with at least
threshold_species_proportion% species present.
Examples
# Get sites with more than 40% of the species
new_site_species <- fb_filter_sites_by_species_coverage(
woodiv_site_species,
threshold_species_proportion = 0.4
)
# There are now only 148 sites
dim(new_site_species)
new_site_species[1:3, 1:4]
Filter sites with a given trait coverage threshold
Description
Select sites (rows of the site_species object) with all given traits
available for at least the user-defined proportion of species
threshold_traits_proportion. If a single trait is given, then the threshold
applies to a single trait, if more than one trait is provided, then the
function considers a threshold across all traits taken together.
Usage
fb_filter_sites_by_trait_coverage(
site_species,
species_traits,
threshold_traits_proportion = 1
)
Arguments
site_species |
a |
species_traits |
a |
threshold_traits_proportion |
a numeric of length 1 between 0 and 1. The percentage trait coverage threshold |
Value
A subset of site_species with sites covered by X% of
abundance/coverage considering all provided traits.
Examples
# Filter all the sites where all species have known traits
new_site_species <- fb_filter_sites_by_trait_coverage(
woodiv_site_species, woodiv_traits
)
# There is only one such site
nrow(new_site_species)
# Filter sites where at least 80% of species have known traits
new_site_species_2 <- fb_filter_sites_by_trait_coverage(
woodiv_site_species, woodiv_traits, threshold_traits_proportion = 0.8
)
# There are now four sites
nrow(new_site_species_2)
Filter species with a given sites coverage threshold
Description
Selects species (columns) for which the percentage of sites where the species is present (distribution value higher than 0 and non-NA) is higher than a user-defined threshold.
Usage
fb_filter_species_by_site_coverage(
site_species,
threshold_sites_proportion = 0
)
Arguments
site_species |
a |
threshold_sites_proportion |
a numeric of length 1 between 0 and 1. The percentage of sites coverage threshold. |
Value
A subset of site_species with species with a prevalence higher
than threshold_sites_proportion.
Examples
# Filter species present in at least 10% of the sites
new_site_species <- fb_filter_species_by_site_coverage(
woodiv_site_species,
threshold_sites_proportion = 0.1
)
new_site_species[1:3, 1:4]
# There are now only 84 species (instead of 149)
ncol(new_site_species)
Filter species with a given traits coverage threshold
Description
Selects species (rows) for which the proportion of traits without
NA (missing trait values) is higher than the user-defined threshold.
It considers as many traits as the ones provided to filter given
the threshold.
Usage
fb_filter_species_by_trait_coverage(
species_traits,
threshold_traits_proportion = 0
)
Arguments
species_traits |
a |
threshold_traits_proportion |
a numeric of length 1 between 0 and 1. The percentage of traits coverage threshold. |
Value
A subset of species_traits with species covered by X% of traits.
Examples
# Filter species that have at least 60% of the traits described
new_species_traits <- fb_filter_species_by_trait_coverage(
woodiv_traits,
threshold_traits_proportion = 0.6
)
# There are now only 93 species
nrow(new_species_traits)
Filter traits with a given species coverage threshold
Description
Selects traits (columns) for which the percentage of species without
NA (missing trait values) is higher than a user-defined threshold.
Usage
fb_filter_traits_by_species_coverage(
species_traits,
threshold_species_proportion = 0
)
Arguments
species_traits |
a |
threshold_species_proportion |
|
Value
A subset of species_traits with traits for the specified
proportion of species.
Examples
# Filter traits that have at least 60% non-missing values
new_species_traits <- fb_filter_traits_by_species_coverage(
woodiv_traits,
threshold_species_proportion = 0.6
)
# There are now only 2 traits
ncol(new_species_traits)
Extract site x locations information from long format data
Description
Convert a flat data.frame with site coordinates into a proper sf object
that can then be used by other functions. This function assumes by default
that the coordinates are given in WGS84 (longitude vs. latitude), but this
can be changed through the crs argument. The function automatically removes
repeated coordinates from the input dataset.
Usage
fb_format_site_locations(
data,
site,
longitude,
latitude,
crs = sf::st_crs(4326),
na_rm = FALSE
)
Arguments
data |
a |
site |
a |
longitude |
a |
latitude |
a |
crs |
a |
na_rm |
a logical value. If |
Value
An sf object with a site column specifying site coordinates.
Examples
filename <- system.file(
"extdata", "woodiv_raw_data.csv",
package = "funbiogeo"
)
all_data <- read.csv(filename)
head(all_data)
site_locations <- fb_format_site_locations(
all_data, "site", "longitude",
"latitude"
)
head(site_locations)
Extract site x species information from long format data
Description
Convert a flat data.frame with species occurrence/abundance at site level
into a proper data.frame object that can then be used by other functions.
The final output contains sites in rows and species in columns.
Usage
fb_format_site_species(data, site, species, value, na_to_zero = TRUE)
Arguments
data |
a |
site |
a |
species |
a |
value |
a |
na_to_zero |
a logical value. If |
Value
A data.frame with sites in rows and species in columns. The first
column is named "site" and contains the name of the sites.
Examples
filename <- system.file(
"extdata", "woodiv_raw_data.csv",
package = "funbiogeo"
)
all_data <- read.csv(filename)
head(all_data)
site_species <- fb_format_site_species(all_data, "site", "species", "count")
site_species[1:3, 1:4]
Extract species x categories information from long format data
Description
Convert a flat data.frame with species names and species (supra-)category
(e.g. family, order, endemism status, etc.) into a proper
species_categories object that can then be used by other functions.
The final output contains species in rows and two columns (species name and
species category).
Usage
fb_format_species_categories(data, species, category)
Arguments
data |
a |
species |
a |
category |
a |
Value
A data.frame with species in rows and two columns (species name and
species category).
Examples
filename <- system.file(
"extdata", "woodiv_raw_data.csv",
package = "funbiogeo"
)
all_data <- read.csv(filename)
head(all_data)
species_categories <- fb_format_species_categories(
all_data, "species", "genus"
)
species_categories[1:6, ]
Extract species x traits information from long format data
Description
Convert a flat data.frame with traits values for different species
into a proper species_traits object that can then be used by other
functions. The final output contains species in rows and traits in columns.
Usage
fb_format_species_traits(data, species, traits)
Arguments
data |
a |
species |
a |
traits |
a |
Value
A data.frame with species in rows and traits in columns, with the
first column names "species" containing the species names.
Examples
filename <- system.file(
"extdata", "woodiv_raw_data.csv", package = "funbiogeo"
)
all_data <- read.csv(filename)
head(all_data)
traits <- c("plant_height", "seed_mass", "sla", "wood_density")
species_traits <- fb_format_species_traits(all_data, "species", traits)
head(species_traits)
Compute Trait Coverage per Site for Each Trait
Description
Compute trait coverage for all sites, i.e., the proportion of total
abundance/presence of species that have traits data compared to total
species. This function assumes that all species provided in the traits
dataset have all their traits specified (meaning that all species have either
known or NA values reported as their traits).
The coverage of each trait separately is returned as well as all traits taken
together if wanted.
Usage
fb_get_all_trait_coverages_by_site(
site_species,
species_traits,
all_traits = TRUE
)
Arguments
site_species |
a |
species_traits |
a |
all_traits |
a logical (default = |
Value
a data.frame with a column with sites and one column per provided
trait giving its coverage (percent species per site, weighted by abundance
that have trait data), and, when argument all_traits = TRUE,
an additional column named all_traits considering the coverage of all
traits taken together.
Examples
site_trait_cov <- fb_get_all_trait_coverages_by_site(
woodiv_site_species, woodiv_traits
)
head(site_trait_cov)
Extract Raster Values at Location of Sites
Description
This function uses a site_locations object and a given SpatRaster.
It extracts the mean value of the provided raster for each site.
Usage
fb_get_environment(site_locations, environment_raster)
Arguments
site_locations |
a |
environment_raster |
a |
Value
A data.frame with average environmental values (columns) per site
(rows), with the first column being "site", indicating site names.
Examples
## Import climate rasters ----
prec <- system.file("extdata", "annual_tot_prec.tif", package = "funbiogeo")
tavg <- system.file("extdata", "annual_mean_temp.tif", package = "funbiogeo")
layers <- terra::rast(c(tavg, prec))
fb_get_environment(head(woodiv_locations), layers)
Compute site trait coverage for each trait combination
Description
This function computes trait coverage for each site for different trait The function will not run if the total number of combinations given is over 10,000.
Usage
fb_get_trait_combination_coverage(
site_species,
species_traits,
comb_size = NULL
)
Arguments
site_species |
a |
species_traits |
a |
comb_size |
an integer vector defining one or more sizes of combinations
over which to compute trait coverage. (default: |
Value
a data.frame with the following columns:
-
sitewith the site indices fromsite_species, -
combination_lengthwith the number of traits in given combinations, -
combination_namewith the name of the trait combination (concatenated trait names with__), -
trait_coveragethe corresponding trait coverage for the given trait combination and site.
Examples
# Compute Coverages using All Trait Combinations
all_combinations <- fb_get_trait_combination_coverage(
woodiv_site_species, woodiv_traits
)
# Get only combinations of 3 traits
three_traits <- fb_get_trait_combination_coverage(
woodiv_site_species, woodiv_traits, 3
)
# Combinations of 2, 3, and 4 traits
two_to_four <- fb_get_trait_combination_coverage(
woodiv_site_species, woodiv_traits, 2:4
)
Compute Trait Coverage For Each Site Weighted by Abundance
Description
Compute trait coverage for all sites, i.e., the proportion of total
abundance/presence of species that have traits data compared to all species.
This function assumes that all species provided in the trait dataset have
all their traits specified (meaning that all species have either known or
NA values reported as their traits).
NB: this function returns trait coverage using all traits
provided in the input species_traits data.frame.
Usage
fb_get_trait_coverage_by_site(site_species, species_traits)
Arguments
site_species |
a |
species_traits |
a |
Value
A data.frame with n rows (where n is the number of sites) and
two columns: site, the site label, and trait_coverage, the percent of
total abundance/presence of species that have traits data.
Examples
site_trait_cov <- fb_get_trait_coverage_by_site(
woodiv_site_species, woodiv_traits
)
head(site_trait_cov)
Create an Rmarkdown Report to Explore User Data
Description
Creates an R Markdown (.Rmd) report from a template to explore and
summarize user data in (functional) biogeography through the use of the
site-species, the species-traits, and the site-locations objects. Users can
modify this report and use the function rmarkdown::render()
(or click the Render of the RStudio IDE) to convert
this .Rmd in different formats:
HTML document (
output_format = "bookdown::html_document2");PDF document (
output_format = "bookdown::pdf_document2");Word document (
output_format = "bookdown::word_document2");HTML, PDF and Word documents (
output_format = "all").
Usage
fb_make_report(
path,
filename = NULL,
title = NULL,
author = NULL,
species_traits,
site_species,
site_locations,
species_categories = NULL,
overwrite = FALSE,
open = TRUE
)
Arguments
path |
a |
filename |
a |
title |
a |
author |
a |
species_traits |
a |
site_species |
a |
site_locations |
a |
species_categories |
(default = |
overwrite |
a logical. If the |
open |
a logical. If |
Details
Note that a copy of user data will be saved as .rds files in
path/funbiogeo/data/ (where path is the directory defined by the user).
Value
No return value.
Examples
if (interactive()) {
# Create temporary folder (optional) ----
temp_path <- tempdir()
# Create report ----
fb_make_report(
path = temp_path,
author = "Casajus N. and Grenié M.",
species_traits = woodiv_traits,
site_species = woodiv_site_species,
site_locations = woodiv_locations,
open = FALSE
)
# Open Rmd file ----
utils::file.edit(file.path(temp_path, "funbiogeo", "funbiogeo_report.Rmd"))
# Render Rmd file ----
rmarkdown::render(
input = file.path(temp_path, "funbiogeo", "funbiogeo_report.Rmd"),
output_format = "all"
)
}
Map a Single Raster Layer
Description
This is a helper function to plot a map of an environmental raster.
The raster is plotted as is, with its given coordinate reference system.
The function can provide a background map if the background argument is
toggled.
Usage
fb_map_raster(x, background = FALSE, ...)
Arguments
x |
a |
background |
a |
... |
other parameters passed to |
Value
A ggplot object.
Examples
library(ggplot2)
## Load raster ----
tavg <- system.file("extdata", "annual_mean_temp.tif", package = "funbiogeo")
tavg <- terra::rast(tavg)
## Default map ----
fb_map_raster(tavg)
## Map with a background ----
fb_map_raster(tavg, background = TRUE)
## Map with custom theme ----
fb_map_raster(tavg, legend.position = "bottom")
## Advanced customization ----
my_map <- fb_map_raster(tavg) +
scale_fill_distiller("Temperature", palette = "Spectral") +
theme(legend.position = "bottom") +
ggtitle("Mean annual temperature in Western Europe")
my_map
## Map w/o annotation ----
fb_map_raster(tavg) +
theme_void() +
theme(legend.position = "none")
Map Arbitrary Site Data
Description
This function helps to map arbitrary site data using the site-locations
object and a dataset organized by site. The returned plot is as little
customized as possible to let the user choose. The function can provide a
basic background map if the background argument is toggled.
Usage
fb_map_site_data(site_locations, site_data, selected_col, background = FALSE)
Arguments
site_locations |
a |
site_data |
|
selected_col |
|
background |
a |
Value
a ggplot object.
Examples
site_rich <- fb_count_species_by_site(woodiv_site_species)
# Map of Species Richness
rich_map <- fb_map_site_data(woodiv_locations, site_rich, "n_species")
rich_map
# Customize the map
rich_map +
ggplot2::scale_fill_viridis_c("Species Richness")
# Map w/ a background
fb_map_site_data(
woodiv_locations, site_rich, "n_species", background = TRUE
)
Map Trait Coverage Per Site
Description
Returns a ggplot2 map of sites colored by trait coverage (proportion
of species having a known trait value). By default shows one plot for each
trait and add an additional facet named "all_traits" considering the
trait coverage with all provided traits taken together.
Usage
fb_map_site_traits_completeness(
site_locations,
site_species,
species_traits,
all_traits = TRUE,
background = FALSE
)
Arguments
site_locations |
a |
site_species |
a |
species_traits |
a |
all_traits |
a logical (default = |
background |
a |
Value
a 'ggplot2' object
Examples
# Map without a background
fb_map_site_traits_completeness(
woodiv_locations, woodiv_site_species, woodiv_traits
)
# Map with a background
fb_map_site_traits_completeness(
woodiv_locations, woodiv_site_species, woodiv_traits, background = TRUE
)
Plot Distribution of Trait Coverages across all Sites
Description
Plots the distributions of trait coverage across site, i.e. the proportion of
species weighted by abundance with known trait values, for each trait
separately and all traits taken together.
The trait distributions are ordered from the lowest to the highest average
trait coverage (top to bottom). The top always displays a distribution named
"all_traits" that contains the distribution of coverage all traits taken
together.
Usage
fb_plot_distribution_site_trait_coverage(
site_species,
species_traits,
species_categories = NULL,
all_traits = TRUE
)
Arguments
site_species |
a |
species_traits |
a |
species_categories |
(default = |
all_traits |
a logical (default = |
Details
Note: this function requires the installation of the ggridges package.
If it isn't installed, the function will give an error suggesting
installing it through install.packages("ggrdiges").
Value
a 'ggplot2' object
Examples
fb_plot_distribution_site_trait_coverage(woodiv_site_species, woodiv_traits)
Plot Number of Sites by Species
Description
Represent all species in each function of the number of sites they occupy. The species are ordered from the ones that occupy the least number of sites from the ones that occupy the most. The number of site is indicated at the bottom x-axis, while the top x-axis represents the proportion of occupied sites. The left y-axis label species names and their rank by increasing prevalence. The user can supplied a threshold of sites to see how many species occupy more or less than the given proportion of sites.
Usage
fb_plot_number_sites_by_species(
site_species,
threshold_sites_proportion = NULL
)
Arguments
site_species |
a |
threshold_sites_proportion |
a numeric of length 1 between 0 and 1. The percentage of sites coverage threshold. |
Value
a ggplot2 object
Examples
fb_plot_number_sites_by_species(woodiv_site_species)
# Add a vertical cutoff line (40% of sites)
fb_plot_number_sites_by_species(woodiv_site_species, 0.4)
Plot Number of Species per Trait
Description
Display a lollipop graph showing the number and proportion of species with non-NA trait for each trait ranked in decreasing order.
Usage
fb_plot_number_species_by_trait(
species_traits,
species_categories = NULL,
threshold_species_proportion = NULL
)
Arguments
species_traits |
a |
species_categories |
(default = |
threshold_species_proportion |
|
Value
a ggplot2 object
Examples
fb_plot_number_species_by_trait(woodiv_traits)
# Add a vertical cutoff line (12.5% of species)
fb_plot_number_species_by_trait(woodiv_traits, NULL, 1/8)
Plot Number of Traits per Species
Description
Display a graph showing the number (and proportion) of species having at least 0, 1, etc. number of traits. It provides a lollipop graph to examine which number of trait cover a certain proportion of the species. This plot doesn't show which traits are concerned.
Usage
fb_plot_number_traits_by_species(
species_traits,
species_categories = NULL,
threshold_species_proportion = NULL
)
Arguments
species_traits |
a |
species_categories |
(default = |
threshold_species_proportion |
|
Value
a ggplot2 object
Examples
fb_plot_number_traits_by_species(woodiv_traits)
# Add a vertical cutoff line (33% of the species)
fb_plot_number_traits_by_species(
woodiv_traits, threshold_species_proportion = 1/3
)
Plot Position of Sites in Environmental Space
Description
Plot a figure showing the average environmental space of given sites compared to a full environmental vector. For the sake of simplicity only represents the figure along two environmental axes. The average environmental value are extracted for each site.
Usage
fb_plot_site_environment(
site_locations,
environment_raster,
first_layer = names(environment_raster)[1],
second_layer = names(environment_raster)[2]
)
Arguments
site_locations |
a |
environment_raster |
a |
first_layer |
|
second_layer |
|
Value
a ggplot object
Examples
# Import climate rasters
prec <- system.file("extdata", "annual_tot_prec.tif", package = "funbiogeo")
tavg <- system.file("extdata", "annual_mean_temp.tif", package = "funbiogeo")
layers <- terra::rast(c(tavg, prec))
# Make plot (show environmental position of 6 first sites)
fb_plot_site_environment(head(woodiv_locations), layers)
Plot Trait Coverage per Site for each Trait
Description
Display a binary heatmap visualizing the site x traits matrix with colors
displaying the proportion of occurring species with known trait values.
Traits are ordered from the most to the least known (left to right).
Sites are ordered from the ones with highest to lowest overall trait coverage
(bottom to top). The site average proportion of species with known trait
for each trait (across all sites) is shown in the x-axis labels.
An additional column at the very right of the plot named "all_traits"
shows a summary considering traits together.
Usage
fb_plot_site_traits_completeness(
site_species,
species_traits,
species_categories = NULL,
all_traits = TRUE
)
Arguments
site_species |
a |
species_traits |
a |
species_categories |
(default = |
all_traits |
a logical (default = |
Value
a ggplot2 object
Examples
fb_plot_site_traits_completeness(woodiv_site_species, woodiv_traits)
Plot Trait Coverage per Species for each Trait
Description
Display a binary heatmap visualizing the species x traits matrix with colors
displaying present and missing traits. Traits are ordered from the most to
the least known (left to right).
Species are ordered from the ones with most to the ones with least traits
(bottom to top). The proportion of species with non-missing traits is shown
on the x-axis labels.
An additional column at the very right of the plot named "all_traits"
shows a summary considering if all other traits are known.
Usage
fb_plot_species_traits_completeness(
species_traits,
species_categories = NULL,
all_traits = TRUE
)
Arguments
species_traits |
a |
species_categories |
(default = |
all_traits |
a logical (default = |
Value
a ggplot2 object
Examples
fb_plot_species_traits_completeness(woodiv_traits)
Plot Trait Coverage per Species for each Trait
Description
Display a binary heatmap visualizing the species x traits matrix with colors
displaying present and missing traits. Traits are ordered from the most to
the least known (left to right).
Species are ordered from the ones with most to the ones with least traits
(bottom to top). The proportion of species with non-missing traits is shown
on the x-axis labels.
An additional column at the very right of the plot named "all_traits"
shows a summary considering if all other traits are known.
Usage
fb_plot_species_traits_missingness(
species_traits,
species_categories = NULL,
all_traits = TRUE
)
Arguments
species_traits |
a |
species_categories |
2-columns |
all_traits |
a logical (default = |
Value
a ggplot2 object
Examples
data(woodiv_traits)
fb_plot_species_traits_missingness(woodiv_traits)
Plot Present and Missing Trait Combinations Frequencies
Description
Display a figure of Present/Missing Trait Combinations where one square is represents one trait. The y-axis gives the frequency of the row (as well as its proportions compared to the total number of rows).
Usage
fb_plot_trait_combination_frequencies(
species_traits,
species_categories = NULL,
order_by = c("number", "complete")
)
Arguments
species_traits |
a |
species_categories |
(default = |
order_by |
|
Value
a ggplot2 object
Examples
# Ordered by number by default
fb_plot_trait_combination_frequencies(woodiv_traits)
# Order by present traits
fb_plot_trait_combination_frequencies(woodiv_traits, NULL, "complete")
Plot Trait Correlation Matrix
Description
This functions outputs a ggplot2 figure that outputs a trait correlation
matrix. It only works on numerical traits and will output messages if
non-numerical traits are found and errors if no numerical traits are found.
Internally it uses the stats::cor() function and only works on complete
observation (it removes any row that contains any NA).
Use the ... argument to pass options to the cor() function.
Usage
fb_plot_trait_correlation(species_traits, species_categories = NULL, ...)
Arguments
species_traits |
a |
species_categories |
(default = |
... |
Additional options passed to |
Value
a ggplot object
Examples
fb_plot_trait_correlation(woodiv_traits)
# Plot Spearman's correlation
fb_plot_trait_correlation(woodiv_traits, method = "spearman")
Summary Table on Traits (Missingness, Range, etc.)
Description
This function outputs a data.frame that summarises the species by trait
table to have many information in a glance. This can then return a data.frame
or a nicely formatted knitr::kable() for inclusion in an Rmarkdown
document.
Usage
fb_table_trait_summary(species_traits, kable = FALSE)
Arguments
species_traits |
a |
kable |
|
Value
a data.frame with the following columns:
-
trait_name: acharactercolumn with the trait name as indicated inspecies_traits -
trait_type: the nature of the trait (numeric,categorical, orordered) -
number_non_missing: the total number of non-NAtrait values -
proportion_non_missing: the proportion of non-NAtrait values -
trait_range: for numerical traits, the range of values -
trait_mean_sd: for numerical traits, the mean plus-minus the standard deviation -
number_distinct: for non-numerical traits, the number of categories -
list_distinct: for non-numerical traits, the list of categories
Examples
# Get a data.frame back
fb_table_trait_summary(woodiv_traits)
# Get a kable (to use in Rmd documents)
fb_table_trait_summary(woodiv_traits, TRUE)
Species x Categories of some Mediterranean Conifers
Description
This dataset is derived from the WOODIV database (available at: https://www.nature.com/articles/s41597-021-00873-3). It contains information (classification, endemism, etc.) of the 24 Conifer tree species occurring in Portugal, Spain, France, and Italy (Mediterranean part). This information will be used as a species grouping factor.
This dataset shows the format of the argument species_categories used in
several functions of funbiogeo. Note that species names must be
the first column and must be named species.
Usage
woodiv_categories
Format
A data.frame with 24 rows (species) and 6 columns (species,
family, genus, binomial, endemism, and cultivated).
References
Monnet AC, Cilleros K, Médail F et al. (2021) WOODIV, a database of occurrences, functional traits, and phylogenetic data for all Euro-Mediterranean trees. Scientific Data, 8, 89. DOI: doi:10.1038/s41597-021-00873-3.
Examples
data("woodiv_categories")
class(woodiv_categories)
dim(woodiv_categories)
woodiv_categories[1:6, ]
Sites x Locations of some Mediterranean Conifers
Description
This dataset is derived from the WOODIV database (available at: https://www.nature.com/articles/s41597-021-00873-3). It contains the grid cells of sites (10 km x 10 km horizontal resolution) sampled in Portugal, Spain, France, and Italy (Mediterranean part) for which at least one of the 24 conifer tree species occurs.
This dataset exemplifies the argument site_locations used in
several functions of funbiogeo. The variable site corresponds to the
site labels (must match the same column in site_species) and the variable
country will be used as a site grouping factor.
Usage
woodiv_locations
Format
An sf POLYGON object with 5,366 rows (grid cells) defined in the
ETRS89-extended / LAEA Europe Coordinate Reference System (EPSG:3035).
References
Monnet AC, Cilleros K, Médail F et al. (2021) WOODIV, a database of occurrences, functional traits, and phylogenetic data for all Euro-Mediterranean trees. Scientific Data, 8, 89. DOI: doi:10.1038/s41597-021-00873-3.
Examples
data("woodiv_locations")
class(woodiv_locations)
dim(woodiv_locations)
head(woodiv_locations)
Sites x Species of some Mediterranean Conifers
Description
This dataset is derived from the WOODIV database (available at:
https://www.nature.com/articles/s41597-021-00873-3). It contains the
presence/absence of the 24 Conifer tree species occurring in Portugal,
Spain, France, and Italy (Mediterranean part). The presence/absence is
available at 5,366 sites (grid cells of 10 x 10 km horizontal resolution).
Sites coordinates are provided in site_locations.
This dataset shows the format of the argument site_species used in
several functions of funbiogeo. Note that site labels must be the first
column and must be named site.
Usage
woodiv_site_species
Format
A data.frame with 5,366 rows (sites) and 25 columns (1 column for
site label and 24 for species occurrence).
References
Monnet AC, Cilleros K, Médail F et al. (2021) WOODIV, a database of occurrences, functional traits, and phylogenetic data for all Euro-Mediterranean trees. Scientific Data, 8, 89. DOI: doi:10.1038/s41597-021-00873-3.
Examples
data("woodiv_site_species")
class(woodiv_site_species)
dim(woodiv_site_species)
woodiv_site_species[1:6, 1:6]
Species x Traits of some Mediterranean Conifers
Description
This dataset is derived from the WOODIV database (available at: https://www.nature.com/articles/s41597-021-00873-3). It contains the values of four functional traits for 24 Conifer tree species occurring in Portugal, Spain, France, and Italy (Mediterranean part).
This dataset shows the format of the argument species_traits used in
several functions of funbiogeo. Note that species names must be
the first column and must be named species.
Usage
woodiv_traits
Format
A data.frame with 24 rows (species) and the following five columns:
- species
species name corresponding to the columns of
site_species- plant_height
adult plant height (in
m)- seed_mass
seed mass (in
g)- sla
specific leaf area, i.e. the ratio between leaf area and dry mass (in
m^{2}\cdot kg^{-1})- wood_density
wood density, i.e. stem specific density (in
kg\cdot dm^{–3})
References
Monnet AC, Cilleros K, Médail F et al. (2021) WOODIV, a database of occurrences, functional traits, and phylogenetic data for all Euro-Mediterranean trees. Scientific Data, 8, 89. DOI: doi:10.1038/s41597-021-00873-3.
Examples
data("woodiv_traits")
class(woodiv_traits)
dim(woodiv_traits)
head(woodiv_traits)