Preprocessing file
This commit is contained in:
parent
740fee4852
commit
f0d381d6a2
1 changed files with 151 additions and 18 deletions
|
|
@ -1,25 +1,27 @@
|
|||
library(dplyr)
|
||||
library(tidyr)
|
||||
library(ggplot2)
|
||||
library(stringr)
|
||||
# library(data.table)
|
||||
library(here)
|
||||
|
||||
full <- read.csv(file.path(
|
||||
here(), "data",
|
||||
"aggregated_dataframe_suppdiplome.csv"
|
||||
"01_aggregated_dataframe_suppdiplome.csv"
|
||||
))
|
||||
|
||||
full[["ine"]] <- as.factor(full[["ine"]])
|
||||
# full[["ine"]] <- as.factor(full[["ine"]])
|
||||
# full[["cours"]] <- as.factor(full[["cours"]])
|
||||
full[["ects"]] <- as.numeric(full[["ects"]])
|
||||
full[["annee"]] <- as.factor(full[["annee"]])
|
||||
full[["type_annee"]] <- as.factor(full[["type_annee"]])
|
||||
full[["bloc"]] <- as.factor(full[["bloc"]])
|
||||
# full[["ects"]] <- as.numeric(full[["ects"]])
|
||||
# full[["annee"]] <- as.factor(full[["annee"]])
|
||||
# full[["type_annee"]] <- as.factor(full[["type_annee"]])
|
||||
# full[["bloc"]] <- as.factor(full[["bloc"]])
|
||||
# full[["parcours"]] <- as.factor(full[["parcours"]])
|
||||
# full[["domaine2A"]] <- as.factor(full[["domaine2A"]])
|
||||
full[["domaine2A"]] <- as.factor(full[["domaine2A"]])
|
||||
# full[["dominante3A"]] <- as.factor(full[["dominante3A"]])
|
||||
|
||||
working_copy <- full
|
||||
|
||||
|
||||
# Correction des typos
|
||||
## Parcours
|
||||
### Suppression des NAs
|
||||
|
|
@ -55,7 +57,8 @@ working_copy[grep(
|
|||
|
||||
working_copy[grep(
|
||||
"Bioraffineries - chimie verte",
|
||||
working_copy[["parcours"]], fixed = TRUE
|
||||
working_copy[["parcours"]],
|
||||
fixed = TRUE
|
||||
), "parcours"] <- "Bioraffinerie, chimie verte"
|
||||
|
||||
working_copy[grep(
|
||||
|
|
@ -83,7 +86,7 @@ if (length(unique(working_copy[["domaine2A"]])) == 6L) {
|
|||
stop("Il faut nettoyer les domaines !")
|
||||
}
|
||||
|
||||
## Dominante
|
||||
## Dominante
|
||||
### Suppression des NAs
|
||||
ine_missing_dominante <- unique(working_copy[is.na(working_copy[["dominante3A"]]), "ine"])
|
||||
|
||||
|
|
@ -110,16 +113,124 @@ message(
|
|||
## Correction mauvais noms de cours
|
||||
working_copy[grep(
|
||||
"Initiation au métier de la recherche",
|
||||
working_copy[["cours"]], fixed = TRUE
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Initiation aux métiers de la recherche"
|
||||
|
||||
working_copy[grep(
|
||||
"Initiation au métier de la recherche",
|
||||
working_copy[["cours"]], fixed = TRUE
|
||||
), "cours"] <- "Initiation aux métiers de la recherche"
|
||||
"Modélisation en biologie des populations: de la structure des génomes à l'extinction des populations",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Modélisation en biologie des populations : de la structure des génomes à l'extinction des populations"
|
||||
|
||||
working_copy[grep(
|
||||
"Aspects Cellulaires et Moléculaires du Vieillissement",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Aspects cellulaires et moléculaires du vieillissement"
|
||||
|
||||
# Importation détails séquences
|
||||
working_copy[grep(
|
||||
"Bioénergies et lignocelluloses",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Bio-energy and ligno-celluloses (in English)"
|
||||
|
||||
working_copy[grep(
|
||||
"Economie écologique",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Économie écologique"
|
||||
|
||||
working_copy[grep(
|
||||
"Fermentation-distillation: des boissons aux biocarburants",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Fermentation-distillation : des boissons aux biocarburants"
|
||||
|
||||
working_copy[grep(
|
||||
"Gènes et nature: les biotechnologies végétales pour une agriculture durable",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Gènes et nature: les biotechnologies végétales au centre de questions de société"
|
||||
|
||||
working_copy[grep(
|
||||
"Marketing des Produits de Grande Consommation",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Marketing des Produits alimentaires et Responsabilité Sociale des Marques"
|
||||
|
||||
working_copy[grep(
|
||||
"Evaluation des modèles d'affaires et transition vers l'économie circulaire",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Evaluation des Modèles d'affaires et transition vers l'économie circulaire"
|
||||
|
||||
working_copy[grep(
|
||||
"Initiation à l'entrepreunariat dans le vivant|Initiation à l'entrepreneuriat dans le vivant",
|
||||
working_copy[["cours"]]
|
||||
), "cours"] <- "Initiation à l'entreprenariat dans le vivant"
|
||||
|
||||
working_copy[grep(
|
||||
"Biodiversité et Evolution",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Biodiversité et évolution"
|
||||
|
||||
working_copy[grep(
|
||||
"Programmer en C, application à des données de télédétection",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Programmer en C"
|
||||
|
||||
working_copy[grep(
|
||||
"Management stratégique, concurrence & marchés",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Management stratégique, concurrence et marchés"
|
||||
|
||||
working_copy[grep(
|
||||
"Produits alimentaires et cosmétiques: structure et caractérisation physique",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Produits alimentaires et cosmétiques : structure et caractérisation physique"
|
||||
|
||||
working_copy[grep(
|
||||
"Introduction à l'hématologie et à l'immunologie",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Introduction à l'immunologie sur le thème de la vaccination"
|
||||
|
||||
working_copy[grep(
|
||||
"Les bois : qualités, exploitation -- Interactions ongulés sauvages et forêt",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Les bois : qualités, exploitation --Interactions ongulés sauvages et forêt"
|
||||
|
||||
working_copy[grep(
|
||||
"Usages et propriétés du bois -- Milieux humides",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Usages et propriétés du bois --Milieux humides"
|
||||
|
||||
working_copy[grep(
|
||||
"Sociologie des systèmes agroalimentaires alternatifs",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Sociologie des systèmes agroalimentaires alternatifs et innovations"
|
||||
|
||||
working_copy[grep(
|
||||
"Milieux humides : connaissance écologique fonctionnelle et floristique",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Milieux humides : définitions, règlementation et gestion"
|
||||
|
||||
working_copy[grep(
|
||||
"Management & Ressources Humaines",
|
||||
working_copy[["cours"]],
|
||||
fixed = TRUE
|
||||
), "cours"] <- "Les relations de travail : Cadre légal et gestion des ressources humaines"
|
||||
|
||||
# Importation détails séquences
|
||||
|
||||
data_sequence <- read.csv(file.path(
|
||||
here(), "data",
|
||||
|
|
@ -128,7 +239,29 @@ data_sequence <- read.csv(file.path(
|
|||
|
||||
joined_data <- full_join(working_copy, data_sequence, by = "cours")
|
||||
|
||||
non_matches <- unique(joined_data[is.na(joined_data[["code_cours"]]) & grepl("(MODULE INTEGRATIF|UE à choix*)", joined_data[["bloc"]]), ][c("cours", "bloc")])
|
||||
write.csv(non_matches,
|
||||
file =
|
||||
file.path(here(), "data", "non-matche.csv")
|
||||
)
|
||||
|
||||
non_matches <- unique(joined_data[is.na(joined_data[["code_cours"]]) & grepl("(MODULE INTEGRATIF|UE à choix*)", joined_data[["bloc"]]),][c("cours", "bloc")])
|
||||
write.csv(non_matches, file =
|
||||
file.path(here(), "data", "non-matche.csv"))
|
||||
filtrage <- function(x) {
|
||||
if (length(x) == 0L) {
|
||||
return("Unknown")
|
||||
}
|
||||
if (length(x) >= 1L) {
|
||||
return(x[[1L]])
|
||||
}
|
||||
}
|
||||
|
||||
out_data <- joined_data[!is.na(joined_data[["code_cours"]]), ] %>%
|
||||
select(c(ine, parcours, domaine2A, dominante3A, code_cours, code_bloc)) %>%
|
||||
pivot_wider(names_from = code_bloc, values_from = code_cours, values_fn = filtrage) %>%
|
||||
filter(!is.na(ine))
|
||||
|
||||
out_data <- out_data %>% relocate(any_of(c("ine", "dominante3A", "parcours", "domaine2A")))
|
||||
|
||||
write.csv(out_data,
|
||||
file.path(here(), "data", "02_preprocessed_data.csv"),
|
||||
row.names = FALSE
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue