Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OutilEnR_EtatdesLieux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
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 Grand Est
SCDD
OutilsEnR
OutilEnR_EtatdesLieux
Commits
f1f4c29e
Commit
f1f4c29e
authored
1 year ago
by
guillaume.jeffroy
Browse files
Options
Downloads
Patches
Plain Diff
Correction d'un bug sur la table des objectifs
parent
918b2504
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/fct_table.R
+22
-8
22 additions, 8 deletions
R/fct_table.R
data-raw/pipeline/3_donnee_tab_accueil.R
+4
-2
4 additions, 2 deletions
data-raw/pipeline/3_donnee_tab_accueil.R
with
26 additions
and
10 deletions
R/fct_table.R
+
22
−
8
View file @
f1f4c29e
...
@@ -68,8 +68,12 @@ prepare_table <- function(ODRE_agg_filtered, label){
...
@@ -68,8 +68,12 @@ prepare_table <- function(ODRE_agg_filtered, label){
# ODRE_agg_filtered$code_typo <-
# ODRE_agg_filtered$code_typo <-
# ODRE_agg_filtered$code_typo %>% stringr::str_replace_all(filiere_labels_select)
# ODRE_agg_filtered$code_typo %>% stringr::str_replace_all(filiere_labels_select)
for
(
key
in
names
(
filiere_labels_select
)){
for
(
key
in
names
(
filiere_labels_select
)){
ODRE_agg_filtered
<-
ODRE_agg_filtered
%>%
mutate
(
code_typo
=
case_when
(
code_typo
==
key
~
filiere_labels_select
[
key
],
ODRE_agg_filtered
<-
ODRE_agg_filtered
%>%
dplyr
::
mutate
(
T
~
code_typo
))
code_typo
=
dplyr
::
case_when
(
code_typo
==
key
~
filiere_labels_select
[
key
],
T
~
code_typo
)
)
}
}
# select, order and cast columns
# select, order and cast columns
...
@@ -167,24 +171,34 @@ table_options_no_button <- function(nb_elements){
...
@@ -167,24 +171,34 @@ table_options_no_button <- function(nb_elements){
#' prepare_table_obj(objectifs, sel_region = "R44", sel_filiere = c("pvq"))
#' prepare_table_obj(objectifs, sel_region = "R44", sel_filiere = c("pvq"))
prepare_table_obj
<-
function
(
objectifs
,
sel_region
,
sel_filiere
)
{
prepare_table_obj
<-
function
(
objectifs
,
sel_region
,
sel_filiere
)
{
for
(
key
in
names
(
filiere_labels_select
)){
objectifs
<-
objectifs
%>%
mutate
(
code_typo
=
case_when
(
code_typo
==
key
~
filiere_labels_select
[
key
],
T
~
code_typo
))
}
objectifs
%>%
objectifs
<-
objectifs
%>%
dplyr
::
filter
(
.data
$
code_typo
%in%
sel_filiere
,
dplyr
::
filter
(
.data
$
code_typo
%in%
sel_filiere
,
paste0
(
"R"
,
.data
$
CodeZone
)
==
sel_region
)
%>%
paste0
(
"R"
,
.data
$
CodeZone
)
==
sel_region
)
%>%
dplyr
::
select
(
dplyr
::
select
(
Année
=
.data
$
annee
,
Année
=
.data
$
annee
,
Énergie
=
.data
$
code_typo
,
Énergie
=
.data
$
code_typo
,
'Production cible SRADDET (GWh)'
=
valeur
,
'Production cible SRADDET (GWh)'
=
.data
$
valeur
,
Zone
=
.data
$
CodeZone
Zone
=
.data
$
CodeZone
)
%>%
)
%>%
dplyr
::
mutate
(
dplyr
::
mutate
(
Énergie
=
factor
(
.data
$
Énergie
),
Zone
=
stringr
::
str_replace_all
(
paste0
(
"R"
,
.data
$
Zone
),
region_names
),
Zone
=
stringr
::
str_replace_all
(
paste0
(
"R"
,
.data
$
Zone
),
region_names
),
Année
=
factor
(
.data
$
Année
)
Année
=
factor
(
.data
$
Année
)
)
)
for
(
key
in
names
(
filiere_labels_select
)){
objectifs
<-
objectifs
%>%
mutate
(
Énergie
=
case_when
(
.data
$
Énergie
==
key
~
filiere_labels_select
[
key
],
T
~
.data
$
Énergie
)
)
}
print
(
objectifs
)
return
(
objectifs
)
}
}
...
...
This diff is collapsed.
Click to expand it.
data-raw/pipeline/3_donnee_tab_accueil.R
+
4
−
2
View file @
f1f4c29e
...
@@ -14,8 +14,10 @@ dta <- registre_ODRE_complet %>%
...
@@ -14,8 +14,10 @@ dta <- registre_ODRE_complet %>%
# On n'utilise pas str_replace_all pour éviter de remplacer iterativement des valeurs au sein d'un string
# On n'utilise pas str_replace_all pour éviter de remplacer iterativement des valeurs au sein d'un string
dta
$
Type
<-
NA
dta
$
Type
<-
NA
for
(
key
in
names
(
filiere_labels_select
)){
for
(
key
in
names
(
filiere_labels_select
)){
dta
<-
dta
%>%
mutate
(
Type
=
case_when
(
code_typo
==
key
~
filiere_labels_select
[
key
],
dta
<-
dta
%>%
mutate
(
Type
=
case_when
(
T
~
Type
))
code_typo
==
key
~
filiere_labels_select
[
key
],
T
~
Type
))
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment