#' Prepare data for trend plots
#'
#' @import dplyr
#'
prep_data_tendances <- function(bnvd_data, top_substances) {
bind_rows(
left_join(x = filter(top_substances, departement != "FRANCE") %>%
select(departement, substance, Rang),
y = bnvd_data,
by = c("departement", "substance")),
left_join(x = filter(top_substances, departement == "FRANCE") %>%
select(departement, substance, Rang),
y = group_by(bnvd_data, annee, substance) %>%
summarise(quantite = sum(quantite)) %>%
mutate(departement = "FRANCE"),
by = c("departement", "substance"))
) %>%
bind_rows(.,
group_by(., departement, annee) %>%
summarise(quantite = sum(quantite)) %>%
mutate(substance = "total phytosanitaires"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.