#' Distribution de fréquence
#'
#' Distribution de fréquence des valeurs
#'
#' @param poly_data Dataset créé par la fonction `polyXXXX_data()`.
#'
#' @import data.table
#' @import ggplot2
#' @export
poly_distFreq <- function(poly_data){
x <- poly_tabFreq(poly_data) # tableau de fréquence
x[, Valeur := as.numeric(Valeur) - 1]
xmax <- max(x$Valeur)
p <- ggplot(x, aes(Valeur, Freq)) +
geom_bar(
stat = "identity",
col = "#5792CC", fill = "#5792CC" # couleur de l'inesss
) +
labs(
title = paste0("Distribution de fréquence des valeurs"), # titre du barplot
x = "Valeur de l'indicateur", # titre axe x
y = "Freq (n)" # titre axe y
) +
scale_y_continuous(expand = c(0, 0)) +
scale_x_continuous(
expand = c(0, 0),
limits = c(-1, xmax+1),
breaks = seq(0, xmax + 1, 2),
labels = sapply(seq(0, xmax + 1, 2), function(x) paste0("[",x,",",x+1,"["))
) +
theme_classic() +
theme(
plot.title = element_text(hjust = 0.5) # centré le titre
)
return(p)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.