From 51e6d43b5d5b154754e545629db3a7b57e992d70 Mon Sep 17 00:00:00 2001 From: Juliette Engelaere-Lefebvre <juliette.engelaere@developpement-durable.gouv.fr> Date: Thu, 18 Jul 2024 18:29:09 +0200 Subject: [PATCH] =?UTF-8?q?Essai=20r=C3=A9paration=20CI=20:=20mise=20?= =?UTF-8?q?=C3=A0=20jour=20de=20l'image=20docker=20de=20d=C3=A9part=20(roc?= =?UTF-8?q?ker/geospatial:latest=20au=20lieu=20de=204.0.1)=20+=20Apurement?= =?UTF-8?q?=20des=20notes=20et=20warnings=20des=20checks=20:=20-=20prefixa?= =?UTF-8?q?ge=20de=20package=20manquants=20-=20utilisation=20des=20''=20au?= =?UTF-8?q?=20lieu=20du=20.data$=20dans=20les=20fonctions=20de=20selection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- DESCRIPTION | 5 ++--- R/creer_graphe_1_4.R | 34 +++++++++++++++++----------------- R/globals.R | 2 +- propre.artificialisation.Rproj | 3 --- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7311ac..ed13e67 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: rocker/geospatial:4.0.1 +image: rocker/geospatial:latest variables: R_LIBS_USER: "ci/lib" diff --git a/DESCRIPTION b/DESCRIPTION index d2a5ec0..4c27922 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,8 +36,7 @@ Imports: stringr, tibble, tidyr, - tricky, - utils + tricky Suggests: rmarkdown, testthat (>= 3.0.0) @@ -53,4 +52,4 @@ Encoding: UTF-8 LazyData: true LazyDataCompression: bzip2 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 diff --git a/R/creer_graphe_1_4.R b/R/creer_graphe_1_4.R index beb472d..3552eb0 100644 --- a/R/creer_graphe_1_4.R +++ b/R/creer_graphe_1_4.R @@ -5,12 +5,12 @@ #' #' @return Un diagramme en barres #' -#' @importFrom dplyr filter select mutate group_by desc arrange case_when +#' @importFrom dplyr filter select mutate group_by desc arrange case_when pull #' @importFrom COGiter filtrer_cog #' @importFrom forcats fct_inorder fct_drop #' @importFrom ggplot2 ggplot aes scale_y_continuous theme geom_text geom_col scale_fill_manual scale_x_discrete coord_flip #' @importFrom glue glue -#' @importFrom lubridate make_date +#' @importFrom lubridate make_date year #' @importFrom tidyr spread gather #' @importFrom tricky set_standard_names #' @importFrom ggtext element_markdown @@ -25,10 +25,10 @@ creer_graphe_1_4 <- function(code_reg){ millesime_teruti <- teruti %>% - dplyr::select(date) %>% + dplyr::select("date") %>% # unique() %>% - pull() %>% - year() %>% + dplyr::pull() %>% + lubridate::year() %>% max() attempt::stop_if(millesime_teruti, is.null, msg = "millesime_teruti n'est pas renseign\u00e9") @@ -53,20 +53,20 @@ creer_graphe_1_4 <- function(code_reg){ dplyr::arrange(.data$typezone,.data$zone) %>% dplyr::mutate(zone = forcats::fct_drop(.data$zone) %>% forcats::fct_inorder(), voiries=.data$sols_revetus, - hors_voiries=(.data$sols_batis+ .data$sols_stabilises+ .data$autres_sols_artificialises ) + hors_voiries=(.data$sols_batis + .data$sols_stabilises + .data$autres_sols_artificialises ) ) %>% - dplyr::select(.data$typezone,.data$codezone,.data$zone,.data$voiries,.data$hors_voiries)%>% - tidyr::gather(variable,valeur,.data$voiries:.data$hors_voiries)%>% - dplyr::mutate(variable = replace(.data$variable, .data$variable=="hors_voiries","surfaces artificialis\u00e9es hors voiries"))%>% - dplyr::mutate(variable=factor(.data$variable,levels=c("surfaces artificialis\u00e9es hors voiries","voiries"))%>% forcats::fct_inorder()) %>% + dplyr::select("typezone", "codezone", "zone", "voiries", "hors_voiries")%>% + tidyr::gather("variable", "valeur", .data$voiries:.data$hors_voiries)%>% + dplyr::mutate(variable = replace(.data$variable, .data$variable == "hors_voiries", "surfaces artificialis\u00e9es hors voiries"))%>% + dplyr::mutate(variable = factor(.data$variable, levels = c("surfaces artificialis\u00e9es hors voiries","voiries")) %>% forcats::fct_inorder()) %>% dplyr::group_by(.data$typezone,.data$codezone,.data$zone) %>% dplyr::arrange(.data$codezone, dplyr::desc(.data$variable))%>% dplyr::mutate(position = cumsum(.data$valeur) - 0.5 * .data$valeur) - graph_1_4<-data %>% + graph_1_4 <- data %>% ggplot2::ggplot(ggplot2::aes(x=.data$zone,y=.data$valeur)) + - ggplot2::geom_col(ggplot2::aes(fill = .data$variable), width = 0.9)+ - ggplot2::geom_text(ggplot2::aes(y = .data$position, label = mapfactory::format_fr(.data$valeur,0), group =.data$variable), color = "white", size=3)+ + ggplot2::geom_col(ggplot2::aes(fill = .data$variable), width = 0.9) + + ggplot2::geom_text(ggplot2::aes(y = .data$position, label = mapfactory::format_fr(.data$valeur,0), group =.data$variable), color = "white", size=3) + ggplot2::labs(title= glue::glue("Etat des surfaces artificialis\u00e9es en {millesime_teruti} (en hectares)"), subtitle=glue::glue("<span style = 'color:{couleur_hors_voirie}'> Hors voiries</span> et <span style = 'color:{couleur_voirie}'> en voiries</span>"), x="", @@ -74,11 +74,11 @@ creer_graphe_1_4 <- function(code_reg){ fill="", caption = glue::glue("Source : Teruti-Lucas {millesime_teruti}"))+ ggplot2::theme(legend.position = "none", - plot.subtitle = ggtext::element_markdown(size = 12, lineheight = 1.2))+ - ggplot2::scale_y_continuous(labels = scales::number_format(suffix = "", accuracy = 1)) + + plot.subtitle = ggtext::element_markdown(size = 12, lineheight = 1.2)) + + ggplot2::scale_y_continuous(labels = scales::number_format(suffix = "", accuracy = 1)) + ggplot2::coord_flip() + - ggplot2::scale_x_discrete(limits=rev) + - ggplot2::scale_fill_manual(values = c(couleur_voirie,couleur_hors_voirie)) + ggplot2::scale_x_discrete(limits = rev) + + ggplot2::scale_fill_manual(values = c(couleur_voirie, couleur_hors_voirie)) return(graph_1_4) diff --git a/R/globals.R b/R/globals.R index 606a3cc..082abd8 100644 --- a/R/globals.R +++ b/R/globals.R @@ -1,4 +1,4 @@ -utils::globalVariables( +globalVariables( c("teruti","observatoire_artificialisation",".data","variable",".", "valeur","etalement_urbain","observatoire_artificialisation_gk3", "stock_artificialise","population_legale","ocsge","regions") diff --git a/propre.artificialisation.Rproj b/propre.artificialisation.Rproj index 4adc5c8..69fafd4 100644 --- a/propre.artificialisation.Rproj +++ b/propre.artificialisation.Rproj @@ -19,7 +19,4 @@ LineEndingConversion: Posix BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageBuildArgs: --no-build-vignettes -PackageBuildBinaryArgs: --no-build-vignettes -PackageCheckArgs: --no-build-vignettes PackageRoxygenize: rd,collate,namespace -- GitLab