#' Title
#'
#' @inheritParams dog_double_count
#'
#' @return A list containing ggplot2 object.
#' @export
#'
#' @examples
#' test <- nycflights13::flights %>%
#' dplyr::mutate(date = lubridate::as_date(paste(year, month, day, sep="-")))
#' cat_barplot_double_count_loop(df = test, date_col = date, categorie_col = carrier)
cat_barplot_double_count_loop <- function(df, date_col, categorie_col) {
data1 <- dog_double_count(df, {{date_col}}, {{categorie_col}}) %>%
dplyr::group_by({{categorie_col}}) %>%
tidyr::nest()
plots_bar <- data1 %>%
mutate(plots = purrr::map2(.x = data, .y = {{categorie_col}} , function(.x, .y){ .x %>%
ggplot(aes(x= forcats::as_factor(.x$n), y=.x$nn)) +
geom_bar(stat="identity") +
geom_text(aes(label = .x$nn), vjust = -.5) +
labs(y = "Antal dage",
x="Antal scanninger",
title = paste0(.y, ": Antal dage med antal scanninger"))
}))
plots_bar$plots
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.