View source: R/indicator_introduction_year.R
indicator_introduction_year | R Documentation |
Calculate how many new species has been introduced in a year.
indicator_introduction_year(
df,
start_year_plot = 1920,
smooth_span = 0.85,
x_major_scale_stepsize = 10,
x_minor_scale_stepsize = 5,
facet_column = NULL,
taxon_key_col = "key",
first_observed = "first_observed",
x_lab = "Year",
y_lab = "Number of introduced alien species"
)
df |
A data frame. |
start_year_plot |
Year where the plot starts from. Default: 1920. |
smooth_span |
(numeric) Parameter for the applied
|
x_major_scale_stepsize |
(integer) Parameter that indicates the breaks of the x axis. Default: 10. |
x_minor_scale_stepsize |
(integer) Parameter that indicates the minor breaks of the x axis. Default: 5. |
facet_column |
NULL or character. The column to use to create additional
facet wrap plots underneath the main graph. When NULL, no facet graph are
created. Valid facet options: |
taxon_key_col |
character. Name of the column of |
first_observed |
character. Name of the column of |
x_lab |
NULL or character. to set or remove the x-axis label. |
y_lab |
NULL or character. to set or remove the y-axis label. |
A list with three slots:
plot
: ggplot2 object (or egg object if facets are used).
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
. If facet_column
is NULL, NULL is returned.
## 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()
)
)
# without facets
indicator_introduction_year(data)
# specify start year and smoother parameter
indicator_introduction_year(data,
start_year_plot = 1940,
smooth_span = 0.6
)
# with facets
indicator_introduction_year(data, facet_column = "kingdom")
# specify columns with year of first observed
indicator_introduction_year(data,
first_observed = "first_observed"
)
# specify axis labels
indicator_introduction_year(data, x_lab = "YEAR", y_lab = NULL)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.