Aperçu des sections

  • Basic concepts

  • Functionnal programming

  • Developing an R package

  • ggplot2

  • R shiny : building interactive graphical applications

    • Practical 1 Interactive visualisation with mtcars

      Objective Create a Shiny application to visualise the relationships between different variables in the mtcars dataset.

      Instructions

      1. Use selectInput() to allow the user to select two numerical variables from the mtcars dataset.
      2. Display an interactive scatter graph (ggplot2).
      3. Add a sliderInput() to adjust the size of the points.
      library(shiny)
      library(ggplot2)

      ui <- fluidPage(
        titlePanel("Visualisation interactive des données mtcars"),
          sidebarPanel(
            selectInput("xvar", "Choisissez la variable X :", choices = names(mtcars)),
            selectInput("yvar", "Choisissez la variable Y :", choices = names(mtcars)),
            sliderInput("pointSize", "Taille des points :", min = 1, max = 10, value = 3)
          ),
          mainPanel(
            plotOutput("scatterPlot"), width = 20)
      )

      server <- function(input, output) {
        output$scatterPlot <- renderPlot({
          ggplot(mtcars, aes_string(x = input$xvar, y = input$yvar)) +
            geom_point(size = input$pointSize, color = "blue") +
            theme_minimal() +
            labs(title = "Graphique de dispersion", x = input$xvar, y = input$yvar)
        })
      }

      shinyApp(ui, server)


      Practical 2 Analysing iris data

      Objective To enable the user to explore iris data using statistics and visualisations.

      Instructions

      1. Add a selectInput() to choose a species (setosaversicolorvirginica).
      2. Filter the data according to the selected species.
      3. Display :
        • statistical summary (summary()) of the numerical variables.
        • boxplot of the distribution of sepal lengths by species (ggplot2).
      library(shiny)
      library(ggplot2)

      ui <- fluidPage(
          sidebarPanel(
            selectInput("species", "Sélectionnez une espèce :", choices = unique(iris$Species))
          ),
          mainPanel(
            verbatimTextOutput("summaryStats"),
            plotOutput("boxplotSepalLength")
          )
      )

      server <- function(input, output) {
        filteredData <- reactive({
          iris[iris$Species==input$species,]
        })
        output$summaryStats <- renderPrint({
          summary(filteredData()[, 1:4])  # Exclure la colonne Species
        })
       
        output$boxplotSepalLength <- renderPlot({
          ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
            geom_boxplot() +
            theme_minimal() +
            labs(title = "Longueur des sépales par espèce")
        })
      }

      shinyApp(ui, server)


      Practical 3 Analysis of the passengers on the Titanic (titanic from the datasets package)

      Objective To study the distribution of passengers according to class and survival.

      Instructions

      1. Load the dataset with data(‘Titanic’) and convert it to data.frame.
      2. Add checkboxGroupInput() to allow the user to filter passengers by class and gender.
      3. Display :
        • reactive array (DT::datatable()).
        • bar chart of the number of survivors and non-survivors (ggplot2).
      titanic_df <- as.data.frame(Titanic)

      ui <- fluidPage(
        titlePanel("Analyse des données Titanic"),
        sidebarLayout(
          sidebarPanel(
            checkboxGroupInput("class", "Choisir la classe :", choices = unique(titanic_df$Class), selected = unique(titanic_df$Class)),
            checkboxGroupInput("sex", "Choisir le sexe :", choices = unique(titanic_df$Sex), selected = unique(titanic_df$Sex))
          ),
          mainPanel(
            DTOutput("tableTitanic"),
            plotOutput("barPlotSurvival")
          )
        )
      )

      server <- function(input, output) {
        filteredData <- reactive({
          titanic_df %>%
            filter(Class %in% input$class, Sex %in% input$sex)
        })
       
        output$tableTitanic <- renderDT({
          datatable(filteredData())
        })
       
        output$barPlotSurvival <- renderPlot({
          ggplot(filteredData(), aes(x = Survived, y = Freq, fill = Survived)) +
            geom_bar(stat = "identity") +
            theme_minimal() +
            labs(title = "Répartition des survivants et non-survivants", x = "Survie", y = "Nombre de passagers")
        })
      }

      shinyApp(ui, server)

  • Rewriting R code in C++

  • Data management

    • library(data.table)
      library(dplyr)
      library(readr)
      library(forcats)

      rg2013.dt <- fread("FrenchOpen-men-2013.csv")
      rg2013.dt

      rg2013.df <- read.table("FrenchOpen-men-2013.csv",sep=",",header=TRUE)
      rg2013.tb <- tibble(rg2013.dt)

      rg2013.tb <- read_csv("FrenchOpen-men-2013.csv")

      rg2013.tb |>
        filter(Round==6) |>
        select(Player1,Player2)

      rg2013.tb |>
        filter(Player1=='Roger Federer' | Player2=='Roger Federer')

      rg2013.tb |>
        distinct(Player2)

      rg2013.tb |>
        mutate(nb_points=TPW.1+TPW.2) |>
        summarise(nb_points_moy=mean(nb_points))

      rg2013.tb |>
        mutate(nb_points=TPW.1+TPW.2) |>
        select(Player1,Player2,nb_points)

      rg2013.tb |> mutate(nb_ace=ACE.1+ACE.2) |>
        group_by(Round) |>
        summarise(min=min(nb_ace),max=max(nb_ace),moy=mean(nb_ace))

      rg2013.tb |> mutate(dbf=DBF.1+DBF.2) |>
        summarize(tot.df=sum(dbf,na.rm=TRUE))

      rg2013.tb |> mutate(dbf=DBF.1+DBF.2) |>
        ggplot() +
        aes(x=dbf) +
        geom_histogram(bins=10) +
        theme_classic()

      rg2013.tb |>
        mutate(dbf=DBF.1+DBF.2) |>
        group_by(Round) |>
        summarize(dbf=mean(dbf,na.rm=TRUE)) |>
        ggplot() +
        aes(x=Round,y=dbf) +
        geom_bar(stat="identity",fill="red") +
        theme_classic()

      rg2013.tb |>
        select(Result, FSP.1, FSP.2) |>
        pivot_longer(cols = c(FSP.1, FSP.2), names_to = "Player", values_to = "FSP") |>
        mutate(Result = as.character((Result == 1 & Player == "FSP.1") | (Result == 0 & Player == "FSP.2"))) |>
        mutate(Result = fct_recode(Result, vic = "TRUE", def = "FALSE")) |>
        ggplot() +
        aes(x = Result, y = FSP) +
        geom_boxplot() +
        theme_classic()

  • R and SQL databases

  • Project

    Submission deadline
    Friday 18 April by email GitHub repository


    SSD


    Groupe 1 : AIGOIN Emilie et THOMAS Anne-Laure
    Groupe 2 : EL QEMMAH Doha et SARIH Kaoutar
    Groupe 3 : CLETZ Laura et STETSUN Kateryna
    Groupe 4 : GERMAIN Marine et ROMANI DE VINCI Coralie
    Groupe 5 : EL MAZZOUJI Wahel et HACHEM REDA    Riwa
    Groupe 6 : MARIAC Damien et BONNEFONT Lucine
    Groupe 7 : GILLET Louison et SCAIA Mattéo
    Groupe 8 : ARMAND Charlotte et DUIGOU Lucien
    Groupe 9 : MAMANE SIDI Samira et MBAYE Rokhaya
    Groupe 10 : OULEBSIR Lamia et RADOUAN Niama
    Groupe 11 : DIALLO Ousmane et SAWADOGO Abdoul-El
    Groupe 12 : CONDAMY Fabian et M'RAD Samy
    Groupe 13 :  ATTOUMANI Ibrahim et OLLIER Julien

    BIOINFORMATIQUE


    Groupe 1 : AIT ALLAOUA Rayane et IBRAHIM AMOUKOU Najat
    Groupe 2 : SANCHEZ Homero et DE LA CHAPELLE Christophe
    Groupe 3 : GALTIER Loik et COQUERELLE Mickael
    Groupe 4 : HOUHOU Yara
  • Evaluation