Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
propre.artificialisation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DREAL Pays de la Loire
Centre de Services de la Donnée
propre.artificialisation
Merge requests
!3
creation du graphique
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
creation du graphique
1-graphique-du-taux-d-artificialisation-par-region-teruti-lucas
into
dev
Overview
0
Commits
16
Pipelines
1
Changes
18
Merged
Daniel.Kalioudjoglou
requested to merge
1-graphique-du-taux-d-artificialisation-par-region-teruti-lucas
into
dev
4 years ago
Overview
0
Commits
16
Pipelines
1
Changes
18
Expand
graphique en barres horizontal
0
0
Merge request reports
Compare
dev
dev (base)
and
latest version
latest version
b2ecf918
16 commits,
4 years ago
18 files
+
357
−
23
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
18
Search (e.g. *.vue) (Ctrl+P)
R/creer_graphe_1_1.R
0 → 100644
+
72
−
0
Options
#' Creation du graphique du taux d'artificialisation par region (Teruti-Lucas)
#' @description Creation du graphique representant le taux d'artificialisation par region (Teruti-Lucas)
#'
#' @param millesime_teruti une année parmi les millesimes sélectionnables par l'utilisateur, au format numerique.
#'
#' @return Un diagramme en barres
#'
#' @importFrom dplyr filter select group_by mutate first ungroup pull
#' @importFrom forcats fct_drop fct_reorder
#' @importFrom ggiraph geom_point_interactive ggiraph
#' @importFrom ggplot2 ggplot aes geom_bar labs scale_y_continuous theme geom_text element_text
#' @importFrom scales number_format
#' @importFrom glue glue
#'
#' @export
#'
#' @examples
#' creer_graphe_1_1(millesime_teruti=2018)
creer_graphe_1_1
<-
function
(
millesime_teruti
){
# Creation de la table utile a la production du graphique
data_france
<-
teruti
%>%
dplyr
::
mutate
(
valeur
=
as.numeric
(
.data
$
valeur
))
%>%
dplyr
::
filter
(
.data
$
CodeZone
==
"FRMETRO"
,
.data
$
date
==
lubridate
::
make_date
(
millesime_teruti
,
"01"
,
"01"
))
%>%
tidyr
::
spread
(
key
=
.data
$
variable
,
value
=
.data
$
valeur
,
fill
=
0
)
%>%
tricky
::
set_standard_names
()
%>%
dplyr
::
mutate
(
taux_artificialisation
=
.data
$
sols_artificiels
/
.data
$
tous_sols
*
100
)
surf_artificialise_france
<-
data_france
%>%
dplyr
::
pull
(
.data
$
sols_artificiels
)
data
<-
teruti
%>%
dplyr
::
mutate
(
valeur
=
as.numeric
(
.data
$
valeur
))
%>%
# Filtres pour ne garder que les donnees de la region et du millesime sélectionne
dplyr
::
filter
(
.data
$
TypeZone
==
"R\u00e9gions"
,
!
(
.data
$
CodeZone
%in%
c
(
"01"
,
"02"
,
"03"
,
"04"
,
"06"
)),
.data
$
date
==
lubridate
::
make_date
(
millesime_teruti
,
"01"
,
"01"
))
%>%
tidyr
::
spread
(
key
=
.data
$
variable
,
value
=
.data
$
valeur
,
fill
=
0
)
%>%
tricky
::
set_standard_names
()
%>%
dplyr
::
mutate
(
taux_artificialisation
=
.data
$
sols_artificiels
/
.data
$
tous_sols
*
100
,
part_dans_surface_nationale
=
.data
$
sols_artificiels
/
surf_artificialise_france
*
100
,
couleur_barre
=
dplyr
::
case_when
(
.data
$
codezone
==
"52"
~
1
,
TRUE
~
0
)
)
%>%
dplyr
::
select
(
.data
$
zone
,
.data
$
taux_artificialisation
,
.data
$
part_dans_surface_nationale
,
.data
$
couleur_barre
)
valeur_max
<-
max
(
data
$
taux_artificialisation
,
na.rm
=
T
)
graph_1_1
<-
data
%>%
ggplot2
::
ggplot
(
ggplot2
::
aes
(
x
=
forcats
::
fct_reorder
(
.data
$
zone
,
.data
$
taux_artificialisation
,
.desc
=
F
),
ymax
=
valeur_max
+4
,
y
=
.data
$
taux_artificialisation
,
fill
=
.data
$
couleur_barre
))
+
ggplot2
::
geom_bar
(
stat
=
"identity"
)
+
ggplot2
::
geom_text
(
ggplot2
::
aes
(
y
=
.data
$
taux_artificialisation
,
label
=
format_fr_pct
(
.data
$
taux_artificialisation
),
color
=
.data
$
couleur_barre
),
position
=
ggplot2
::
position_dodge
(
width
=
1
),
vjust
=
0.5
,
hjust
=
-0.5
,
size
=
3
)
+
ggplot2
::
coord_flip
(
expand
=
FALSE
)
+
ggplot2
::
labs
(
title
=
glue
::
glue
(
"Taux d'artificialisation par r\u00e9gion en {millesime_teruti}"
),
subtitle
=
""
,
x
=
""
,
y
=
""
,
fill
=
""
,
caption
=
glue
::
glue
(
"Source : Teruti-Lucas {millesime_teruti}"
))
+
ggplot2
::
theme
(
axis.text.x
=
ggplot2
::
element_text
(),
legend.position
=
"none"
)
+
ggplot2
::
scale_y_continuous
(
labels
=
scales
::
number_format
(
suffix
=
" %"
,
accuracy
=
1
))
return
(
graph_1_1
)
}
Loading