
Plot number of introduced taxa for CBD pathways level 1
Source:R/visualize_pathways_level1.R
visualize_pathways_level1.RdFunction to plot bar graph with number of taxa introduced by different
pathways at level 1. Possible breakpoints: taxonomic (kingdoms +
vertebrates/invertebrates) and temporal (lower limit year). Facets can be
added (see argument facet_column).
Usage
visualize_pathways_level1(
df,
category = NULL,
from = NULL,
facet_column = NULL,
pathways = NULL,
pathway_level1_names = "pathway_level1",
taxon_names = "key",
kingdom_names = "kingdom",
phylum_names = "phylum",
first_observed = "first_observed",
cbd_standard = TRUE,
title = NULL,
x_lab = "Number of introduced taxa",
y_lab = "Pathways"
)Arguments
- df
A data frame.
- category
NULLor character. One of the kingdoms as given in GBIF andChordata(the phylum),Not Chordata(all other phyla ofAnimalia): 1.Plantae2.Animalia3.Fungi4.Chromista5.Archaea6.Bacteria7.Protozoa8.Viruses9.incertae sedis10.Chordata11.Not ChordataDefault:NULL.- from
NULLor numeric. Year trade-off: select only pathways related to taxa introduced during or after this year. Default:NULL.- facet_column
NULL(default) or character. The column to use to create additional facet wrap bar graphs underneath the main graph. WhenNULL, no facet graph are created. One offamily,order,class,phylum,locality,native_range,habitat. If column has another name, rename it before calling this function. Facetphylumis not allowed in combination withcategoryequal to"Chordata"or"Not Chordata". Facetkingdomis allowed only with category equal toNULL.- pathways
character. Vector with pathways level 1 to visualize. The pathways are displayed following the order as in this vector.
- pathway_level1_names
character. Name of the column of
dfcontaining information about pathways at level 1. Default:pathway_level1.- taxon_names
character. Name of the column of
dfcontaining information about taxa. This parameter is used to uniquely identify taxa.- kingdom_names
character. Name of the column of
dfcontaining information about kingdom. Default:"kingdom".- phylum_names
character. Name of the column of
dfcontaining information about phylum. This parameter is used only ifcategoryis one of:"Chordata","Not Chordata". Default:"phylum".- first_observed
character. Name of the column of
dfcontaining information about year of introduction. Default:"first_observed".- cbd_standard
logical. If TRUE the values of pathway level 1 are checked based on CBD standard as returned by
pathways_cbd(). Error is returned if unmatched values are found. If FALSE, a warning is returned. Default: TRUE.- title
NULLor character. Title of the graph. Default:NULL.- x_lab
NULLor character. x-axis label. Default:"Number of introduced taxa".- y_lab
NULLor character. Title of the graph. Default:"Pathways".
Value
A list with three slots:
plot: ggplot2 object (or egg object if facets are used).NULLif there are no data to plot.data_top_graph: data.frame (tibble) with data used for the main plot (top graph) inplot.data_facet_graph: data.frame (tibble) with data used for the faceting plot inplot.NULLis returned iffacet_columnisNULL.
Examples
if (FALSE) { # \dontrun{
library(readr)
datafile <- paste0(
"https://raw.githubusercontent.com/trias-project/indicators/master/data/",
"interim/data_input_checklist_indicators.tsv"
)
data <- read_tsv(datafile,
na = "NA",
col_types = cols(
.default = col_character(),
key = col_double(),
nubKey = col_double(),
speciesKey = col_double(),
acceptedKey = col_double(),
first_observed = col_double(),
last_observed = col_double()
)
)
# All taxa
visualize_pathways_level1(data)
# Animalia
visualize_pathways_level1(data, category = "Animalia")
# Chordata
visualize_pathways_level1(data, category = "Chordata")
# facet phylum
visualize_pathways_level1(
data,
category = "Animalia",
facet_column = "phylum"
)
# facet habitat
visualize_pathways_level1(data, facet_column = "habitat")
# Only taxa introduced from 1950
visualize_pathways_level1(data, from = 1950)
# Only taxa with pathways "corridor" and "escape"
visualize_pathways_level1(data, pathways = c("corridor", "escape"))
# Add a title
visualize_pathways_level1(
data,
category = "Plantae",
from = 1950,
title = "Plantae - Pathway level 1 from 1950"
)
# Personalize axis labels
visualize_pathways_level1(data, x_lab = "Aantal taxa", y_lab = "pathways")
} # }