You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.1KB

  1. library(tidyverse)
  2. library(shiny)
  3. library(DT)
  4. library(RSQLite)
  5. library(stringr)
  6. library(plotly)
  7. library(forcats)
  8. library(markdown)
  9. uniq <- function(df, ...)
  10. {
  11. eval(substitute(alist(...))) %>%
  12. map_chr(as.character) %>%
  13. intersect(names(df)) %>%
  14. map(~rle(df[[.x]] %>% c) %>%
  15. .$lengths %>%
  16. cumsum) %>%
  17. reduce(union) %>%
  18. sort -> columns
  19. df[columns,]
  20. }
  21. Sys.setlocale("LC_TIME", "fr_FR.UTF-8")
  22. dbConnect(SQLite(), "ecn.db") -> db
  23. # Index villes et spés ----
  24. db %>%
  25. tbl("trajectoires") %>%
  26. select(Discipline, Subdivision) %>%
  27. distinct %>%
  28. collect -> villespe
  29. villespe %>%
  30. select(Subdivision) %>%
  31. distinct %>%
  32. filter(Subdivision != "") %>%
  33. arrange(Subdivision) %>%
  34. pull(Subdivision) -> villes
  35. villespe %>%
  36. select(Discipline) %>%
  37. distinct %>%
  38. filter(!Discipline %>% str_detect("(car aucun vœu)|(malgré.*)|(pas de.*)")) %>%
  39. arrange(Discipline) %>%
  40. pull(Discipline) -> spes
  41. # Max rank ----
  42. db %>%
  43. tbl("trajectoires") %>%
  44. select(Etudiant) %>%
  45. distinct %>%
  46. collect %>%
  47. pull(Etudiant) %>%
  48. max ->
  49. max_rank
  50. db %>% dbDisconnect