View source: R/visualize_pathways_year_level1.R
visualize_pathways_year_level1 | R Documentation |
Function to plot a line graph with number of taxa introduced over time through different CBD pathways level 1. Time expressed in years. Possible breakpoints: taxonomic (kingdoms + vertebrates/invertebrates).
visualize_pathways_year_level1(
df,
bin = 10,
from = 1950,
category = 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 = "Time period",
y_lab = "Number of introduced taxa"
)
df |
A data frame. |
bin |
numeric. Time span in years to use for agggregation. Default:
|
from |
numeric. Year trade-off: taxa introduced before this year are
grouped all together. Default: |
category |
|
facet_column |
|
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 |
taxon_names |
character. Name of the column of |
kingdom_names |
character. Name of the column of |
phylum_names |
character. Name of the column of |
first_observed |
character. Name of the column of |
cbd_standard |
logical. If |
title |
|
x_lab |
|
y_lab |
|
A list with three slots:
plot
: ggplot2 object (or egg object if facets are used). NULL
if there
are no data to plot.
data_top_graph
: data.frame (tibble) with data used for the main plot (top
graph) in plot
.
data_facet_graph
: data.frame (tibble) with data used for the faceting
plot in plot
. NULL
is returned if facet_column
is NULL
.
## Not run:
library(readr)
datafile <- paste0(
"https://raw.githubusercontent.com/trias-project/indicators/master/data/",
"interim/data_input_checklist_indicators.tsv"
)
data <- read_tsv(datafile,
na = "",
col_types = cols(
.default = col_character(),
key = col_double(),
nubKey = col_double(),
speciesKey = col_double(),
first_observed = col_double(),
last_observed = col_double()
)
)
# All taxa
visualize_pathways_year_level1(data)
# Animalia
visualize_pathways_year_level1(data, category = "Animalia")
# Chordata
visualize_pathways_year_level1(data, category = "Chordata")
# Group by 20 years
visualize_pathways_year_level1(data, bin = 20)
# Group taxa introudced before 1970 alltogether
visualize_pathways_year_level1(data, from = 1970)
# facet locality
visualize_pathways_year_level1(
data,
category = "Not Chordata",
facet_column = "locality"
)
# facet habitat
visualize_pathways_year_level1(data, facet_column = "habitat")
# Only taxa with pathways "corridor" and "escape"
visualize_pathways_year_level1(data, pathways = c("corridor", "escape"))
# Add a title
visualize_pathways_year_level1(
data,
category = "Plantae",
from = 1950,
title = "Pathway level 1: Plantae"
)
# Personalize axis labels
visualize_pathways_year_level1(
data,
x_lab = "Jaar",
y_lab = "Aantal geïntroduceerde taxa"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.