R/poly_distCumul.R

Defines functions poly_distCumul

Documented in poly_distCumul

#' Distribution
#'
#' Distribution cumulée des valeurs
#'
#' @param poly_data Dataset créé par la fonction `polyXXXX_data()`.
#'
#' @import data.table
#' @import ggplot2
#' @export
poly_distCumul <- 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, Cumul)) +
    geom_line(col = "#5792CC") +
    geom_point(col = "#5792CC") +
    labs(
      title = paste("Distribution cumulée des valeurs"),
      x = "Valeur de l'indicateur",
      y = "Pourcentage cumulé (%)"
    ) +
    scale_y_continuous(
      expand = c(0, 0),
      limits = c(0, 105),
      breaks = seq(0, 105, 10),
      labels = seq(0, 105, 10)
    ) +
    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)
    )
}
INESSS-QC/polymed1 documentation built on Aug. 4, 2020, 12:02 a.m.