Create an interactive plot for the number of alien species per native region and year of introduction
Source:R/indicator_native_range_year.R
indicator_native_range_year.Rd
Based on countYearProvince plot from reporting - rshiny - grofwildjacht
Usage
indicator_native_range_year(
df,
years = NULL,
type = c("native_range", "native_continent"),
x_major_scale_stepsize = 10,
x_lab = "year",
y_lab = "alien species",
response_type = c("absolute", "relative", "cumulative"),
relative = lifecycle::deprecated(),
taxon_key_col = "key",
first_observed = "first_observed"
)
Arguments
- df
input data.frame.
- years
(numeric) vector years we are interested to. If
NULL
(default) all years from minimum and maximum of years of first observation are taken into account.- type
character, native_range level of interest should be one of
c("native_range", "native_continent")
. Default:"native_range"
. A column called as the selectedtype
must be present indf
.- x_major_scale_stepsize
(integer) Parameter that indicates the breaks of the x axis. Default: 10.
- x_lab
character string, label of the x-axis. Default: "year".
- y_lab
character string, label of the y-axis. Default: "number of alien species".
- response_type
(character) summary type of response to be displayed; should be one of
c("absolute", "relative", "cumulative")
. Default:"absolute"
. If "absolute" the number per year and location is displayed; if "relative" each bar is standardised per year before stacking; if "cumulative" the cumulative number over years per location.- relative
(logical) if
TRUE
each bar is standardised before stacking. Deprecated, useresponse_type = "relative"
instead.- taxon_key_col
character. Name of the column of
df
containing taxon IDs. Default:"key"
.- first_observed
(character) Name of the column in
data
containing temporal information about introduction of the alien species. Expressed as years.
Value
list with:
static_plot
: ggplot object, for a given species the observed number per year and per native range is plotted in a stacked bar chart.interactive_plot
: plotly object, for a given species the observed number per year and per native range is plotted in a stacked bar chart.data
: data displayed in the plot, as a data.frame with:year
: year at which the species were introduced.native_range
: native range of the introduced species.n
: number of species introduced from the native range for a given year.total
: total number of species, from all around the world, introduced. during a given year.perc
: percentage of species introduced from the native range for a given year,n
/total
*100.
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 = "",
col_types = cols(
.default = col_character(),
key = col_double(),
nubKey = col_double(),
speciesKey = col_double(),
first_observed = col_double(),
last_observed = col_double()
)
)
indicator_native_range_year(data, "native_continent", years = c(2010,2013))
} # }