Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • dreal-pdl/csd/zaer
1 result
Select Git revision
Show changes
Commits on Source (2)
......@@ -24,73 +24,8 @@ library(RPostgres)
```
```{r Chargement de la table synthese_valeurs_production sur le serveur,echo = FALSE, warning = FALSE, message=FALSE}
chemin_fichier <- "T:/datalab/MECC/MECC_ZAER/PRODUCTION/valorisation/synthese_valeurs_production.xlsx"
synthese_vals_production <- readxl::read_excel(chemin_fichier, sheet = "synthese")
datamart = datalibaba::connect_to_db("datamart", user = "does")
datalibaba::post_data(
con = datamart,
data = synthese_vals_production,
schema = "zaer",
table = "synthese_valeurs_production",
overwrite = TRUE
)
```
```{r fonction pour renommer les noms de colonnes de la table synthese_valeurs_production, echo = FALSE, warning = FALSE, message=FALSE}
rename_columns <- function(con, db, schema, table, nouvelles_colnames, overwrite = TRUE) {
# Importer la table
data <- datalibaba::importer_data(
table = table,
schema = schema,
db = db,
user = "does"
)
# Vérifier que le nombre de nouvelles colonnes correspond
if (length(nouvelles_colnames) != ncol(data)) {
stop("Le nombre de nouveaux noms de colonnes doit correspondre au nombre de colonnes existantes.")
}
# Renommer les colonnes
colnames(data) <- nouvelles_colnames
# Réécrire la table dans PostgreSQL
datalibaba::post_data(
con = con,
data = data,
schema = schema,
table = table,
overwrite = overwrite
)
message("Les noms de colonnes ont été modifiés avec succès !")
}
```
```{r renommer les noms de colonnes de la table synthese_valeurs_production, echo = FALSE, warning = FALSE, message=FALSE}
noms_propres <- c(
"filieres",
"production_existante", "projets_en_voie_de_realisation",
"production_estimee", "objectif_sraddet_2030",
"taux_de_realisation_bas", "production_ponderee_au_tx_de_realisation_bas",
"taux_de_realisation_haut", "production_ponderee_au_tx_de_realisation_haut",
"taux_de_realisation_pour_atteindre_lobjectif"
)
# Appel de la fonction
rename_columns(
con = datamart ,
db = "datamart",
schema = "zaer",
table = "synthese_valeurs_production",
nouvelles_colnames = noms_propres,
overwrite = TRUE
)
```
```{r chargement des données,echo = FALSE, warning = FALSE, message=FALSE}
role <- "dreal"
role <- "csd"
datamart <- datalibaba::connect_to_db("datamart", user = role)
com_etat_avancement <- datalibaba::importer_data(table = "com_etat_avancement" ,schema ="zaer", db = "datamart", server = NULL, user = role)
com_ration_surface_filiere <- datalibaba::importer_data(table = "com_ration_surface_filiere", schema ="zaer", db = "datamart", server = NULL, user = role)
......@@ -102,7 +37,7 @@ reg_filiere_zaer <- datalibaba::importer_data(table = "reg_filiere_zaer", schema
dep_ssfiliere_zaer <- datalibaba::importer_data(table = "dep_ssfiliere_zaer", schema ="zaer", db = "datamart", server = NULL, user = role)
reg_ssfiliere_zaer <- datalibaba::importer_data(table = "reg_ssfiliere_zaer", schema = "zaer", db = "datamart", server = NULL, user = role)
puissance_productible <- datalibaba::importer_data(table = "puissance_productible", schema = "zaer", db = "datamart", server = NULL, user = role)
synthese_valeurs_production <- datalibaba::importer_data(table = "synthese_valeurs_production", schema = "zaer", db = "datamart", server = NULL, user = "does")
synthese_valeurs_production <- datalibaba::importer_data(table = "synthese_valeurs_production", schema = "zaer", db = "datamart", server = NULL, user = role)
```
......@@ -1129,7 +1064,7 @@ data <- data.frame(
production_existante + production_estimee),
fill = c("white", "white", col1),
border = c(col1, col1, col1),
label = c(production_existante, projets_realisation, production_estimee)
label = round(c(production_existante, projets_realisation, production_estimee))
)
......@@ -1211,7 +1146,7 @@ data <- data.frame(
production_existante + production_estimee),
fill = c("white", "white", col1),
border = c(col1, col1, col1),
label = c(production_existante, projets_realisation, production_estimee)
label = round(c(production_existante, projets_realisation, production_estimee))
)
taux_realisation_bas <- as.integer(synthese_valeurs_production_SOLAIRE_PV$taux_de_realisation_bas * 100)
......@@ -1366,7 +1301,7 @@ data <- data.frame(
production_existante + production_estimee),
fill = c("white", "white", col1),
border = c(col1, col1, col1),
label = c(production_existante, projets_realisation, production_estimee)
label = round(c(production_existante, projets_realisation, production_estimee))
)
taux_realisation_bas <- as.integer(synthese_valeurs_production_HYDROELECTRICITE$taux_de_realisation_bas * 100)
......@@ -1446,7 +1381,7 @@ data <- data.frame(
production_existante + production_estimee),
fill = c("white", "white", col1),
border = c(col1, col1, col1),
label = c(production_existante, projets_realisation, production_estimee)
label = round(c(production_existante, projets_realisation, production_estimee))
)
taux_realisation_bas <- as.integer(synthese_valeurs_production_SOLAIRE_THERMIQUE$taux_de_realisation_bas * 100)
......@@ -1525,7 +1460,7 @@ data <- data.frame(
production_existante + production_estimee),
fill = c("white", "white", col1),
border = c(col1, col1, col1),
label = c(production_existante, projets_realisation, production_estimee)
label = round(c(production_existante, projets_realisation, production_estimee))
)
taux_realisation_bas <- as.integer(synthese_valeurs_production_EOLIEN$taux_de_realisation_bas * 100)
......@@ -1605,7 +1540,7 @@ data <- data.frame(
production_existante + production_estimee),
fill = c("white", "white", col1),
border = c(col1, col1, col1),
label = c(production_existante, projets_realisation, production_estimee)
label = round(c(production_existante, projets_realisation, production_estimee))
)
taux_realisation_bas <- as.integer(synthese_valeurs_production_BOIS_ENERGIE$taux_de_realisation_bas * 100)
......@@ -1686,7 +1621,7 @@ data <- data.frame(
production_existante + production_estimee),
fill = c("white", "white", col1),
border = c(col1, col1, col1),
label = c(production_existante, projets_realisation, production_estimee)
label = round(c(production_existante, projets_realisation, production_estimee))
)
taux_realisation_bas <- as.integer(synthese_valeurs_production_BIOMETHANE$taux_de_realisation_bas * 100)
......
This diff is collapsed.