|
|
@@ -39,8 +39,7 @@ server <- shinyServer(function(input, output, session) |
|
|
|
format(format = "%A %d %B %Y %H:%M") %>% |
|
|
|
str_to_title) -> epoch |
|
|
|
|
|
|
|
list(p(str_c("Données à partir du ", epoch[1])), |
|
|
|
p(str_c("Dernières données du ", epoch[2]))) |
|
|
|
list(p(str_c("Données enregistrées du ", epoch[1], " au ", epoch[2]))) |
|
|
|
}) |
|
|
|
|
|
|
|
# Listing ---- |
|
|
@@ -52,7 +51,8 @@ server <- shinyServer(function(input, output, session) |
|
|
|
ungroup %>% |
|
|
|
mutate(Etudiant = Etudiant %>% as.numeric, |
|
|
|
Subdivision = Subdivision %>% as.factor, |
|
|
|
Discipline = Discipline %>% as.factor) %>% |
|
|
|
Discipline = Discipline %>% as.factor, |
|
|
|
Etat = Etat %>% as.factor) %>% |
|
|
|
arrange(Etudiant) %>% |
|
|
|
select(Etudiant, Etat, Absence, `Vœu`, Subdivision, Discipline, Rang, Date) |
|
|
|
}) |
|
|
@@ -107,7 +107,7 @@ server <- shinyServer(function(input, output, session) |
|
|
|
rownames = F |
|
|
|
) |
|
|
|
|
|
|
|
output$plotEtudiant <- renderPlotly( |
|
|
|
plotEtudiant <- reactive( |
|
|
|
{ |
|
|
|
req(listingEtudiant()) |
|
|
|
|
|
|
@@ -115,11 +115,14 @@ server <- shinyServer(function(input, output, session) |
|
|
|
select(Etudiant, Subdivision, Discipline, Date, Vœu) %>% |
|
|
|
uniq(Subdivision, Discipline) %>% |
|
|
|
unite(Choix, Subdivision, Discipline, sep = " - ") %>% |
|
|
|
mutate(Date = Date %>% as.POSIXct) %>% |
|
|
|
arrange(Date) -> |
|
|
|
plotEtudiant |
|
|
|
mutate(Date = Date %>% as.POSIXct) |
|
|
|
}) |
|
|
|
|
|
|
|
plotEtudiant %>% |
|
|
|
output$plotEtudiant <- renderPlotly( |
|
|
|
{ |
|
|
|
req(plotEtudiant()) |
|
|
|
|
|
|
|
plotEtudiant() %>% |
|
|
|
ggplot(aes(x = Date, y = Choix, group = Etudiant)) + |
|
|
|
geom_step() + |
|
|
|
geom_point() + |
|
|
@@ -136,9 +139,38 @@ server <- shinyServer(function(input, output, session) |
|
|
|
Discipline == input$Spe) -> lst |
|
|
|
|
|
|
|
if (nrow(lst) == 0) |
|
|
|
{ |
|
|
|
NULL |
|
|
|
} |
|
|
|
else |
|
|
|
lst |
|
|
|
{ |
|
|
|
lst$Etudiant %>% |
|
|
|
unique -> etudiants |
|
|
|
|
|
|
|
db() %>% |
|
|
|
filter(Etudiant %in% etudiants) %>% |
|
|
|
mutate(Etudiant = Etudiant %>% factor, |
|
|
|
Rang = if(Rang %>% is.character) Rang %>% str_replace("(\\d+)(/\\d+)?", "\\1") %>% as.numeric else Rang) %>% |
|
|
|
mutate(Rang = ifelse(Subdivision != input$Ville | Discipline != input$Spe, -1, Rang)) %>% |
|
|
|
select(Date, Etudiant, Rang) %>% |
|
|
|
uniq(Etudiant, Rang) %>% |
|
|
|
complete(Etudiant, Date) %>% |
|
|
|
by(.$Etudiant, function(df) |
|
|
|
{ |
|
|
|
which(df$Rang %>% is.na & !lead(df$Rang) %>% is.na) -> chg |
|
|
|
which(!df$Rang %>% is.na & lead(df$Rang) %>% is.na) -> chg2 |
|
|
|
|
|
|
|
df$Rang[setdiff(chg, 1)] <- df$Rang[chg2] |
|
|
|
if (last(df$Rang) %>% is.na) |
|
|
|
df$Rang[length(df$Rang)] <- na.omit(df$Rang)[length(na.omit(df$Rang))] |
|
|
|
|
|
|
|
df %>% |
|
|
|
filter(!Rang %>% is.na) |
|
|
|
}) %>% |
|
|
|
Reduce(f = bind_rows) %>% |
|
|
|
select(Date, Etudiant, Rang) %>% |
|
|
|
mutate(Rang = ifelse(Rang == -1, NA, Rang)) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
tableVilleSpe <- reactive ( |
|
|
@@ -148,6 +180,7 @@ server <- shinyServer(function(input, output, session) |
|
|
|
listingVilleSpe() %>% |
|
|
|
select(Date, Etudiant, Rang) %>% |
|
|
|
group_by(Etudiant) %>% |
|
|
|
filter(!Rang %>% is.na) %>% |
|
|
|
filter(Date == max(Date)) %>% |
|
|
|
ungroup %>% |
|
|
|
arrange(Date) |
|
|
@@ -168,43 +201,15 @@ server <- shinyServer(function(input, output, session) |
|
|
|
{ |
|
|
|
req(listingVilleSpe()) |
|
|
|
|
|
|
|
listingVilleSpe()$Etudiant %>% |
|
|
|
unique -> etudiants |
|
|
|
|
|
|
|
db() %>% |
|
|
|
filter(Etudiant %in% etudiants) %>% |
|
|
|
mutate(Date = Date %>% |
|
|
|
as.POSIXct, |
|
|
|
Etudiant = Etudiant %>% factor, |
|
|
|
Rang = if(Rang %>% is.character) Rang %>% str_replace("(\\d+)(/\\d+)?", "\\1") %>% as.numeric else Rang) %>% |
|
|
|
mutate(Rang = ifelse(Subdivision != input$Ville | Discipline != input$Spe, -1, Rang)) %>% |
|
|
|
select(Date, Etudiant, Rang) %>% |
|
|
|
uniq(Etudiant, Rang) %>% |
|
|
|
complete(Etudiant, Date) %>% |
|
|
|
by(.$Etudiant, function(df) |
|
|
|
{ |
|
|
|
which(df$Rang %>% is.na & !lead(df$Rang) %>% is.na) -> chg |
|
|
|
which(!df$Rang %>% is.na & lead(df$Rang) %>% is.na) -> chg2 |
|
|
|
|
|
|
|
df$Rang[setdiff(chg, 1)] <- df$Rang[chg2] |
|
|
|
if (last(df$Rang) %>% is.na) |
|
|
|
df$Rang[length(df$Rang)] <- na.omit(df$Rang)[length(na.omit(df$Rang))] |
|
|
|
|
|
|
|
df %>% |
|
|
|
filter(!Rang %>% is.na) |
|
|
|
}) %>% |
|
|
|
Reduce(f = bind_rows) %>% |
|
|
|
select(Date, Etudiant, Rang) %>% |
|
|
|
mutate(Rang = ifelse(Rang == -1, NA, Rang)) -> |
|
|
|
plotVilleSpe |
|
|
|
|
|
|
|
plotVilleSpe %>% |
|
|
|
listingVilleSpe() %>% |
|
|
|
mutate(Date = Date %>% as.POSIXct) %>% |
|
|
|
ggplot(aes(x = Date, y = Rang, color = Etudiant, key = Etudiant)) + |
|
|
|
geom_line() + |
|
|
|
geom_point(data = plotVilleSpe %>% |
|
|
|
geom_point(data = listingVilleSpe() %>% |
|
|
|
mutate(Date = Date %>% as.POSIXct) %>% |
|
|
|
group_by(Etudiant) %>% |
|
|
|
filter(!Rang %>% is.na & (lag(Rang) %>% is.na | lead(Rang) %>% is.na))) + |
|
|
|
scale_y_continuous(trans = "reverse", breaks = unique(plotVilleSpe$Rang)) |
|
|
|
scale_y_continuous(trans = "reverse", breaks = unique(listingVilleSpe()$Rang)) |
|
|
|
}) |
|
|
|
|
|
|
|
# Interactivity ---- |
|
|
|