script_app_web_P1.
R
Administrateur Marc
2021-07-02
library(shiny)
library(shinydashboard)
library(DT)
library(rio)
library(ggplot2)
library(GGally)
# 1ere partie
# partie utilisateur qui est visible au demarrage de l'application
ui <- dashboardPage(title = "Programmation R",
dashboardHeader(title = "ma 1ere application"),
dashboardSidebar(fileInput(inputId = "navig",
buttonLabel = "cliquer ici",
label = "importer un fichier",
placeholder = "aucun fichier",
accept = c(".txt", ".xlsx", ".csv", ".dta")
),
# ajout des menus (des liens de page) dans la barre lattérale
sidebarMenu(menuItem("tableau", tabName = "tbl"),
menuItem("resume graphique", tabName = "rg")))
,
dashboardBody(
tabItems(tabItem(tabName = "tbl",
DTOutput(outputId = "tableau")),
tabItem(tabName = "rg", plotOutput("rsg"),
plotOutput("graph"))))
)
# 2e partie
# partie code qui permet l'execution des tache necessaire a l'utlisateur
server <- function(input, output) {
# importation et lecture du fichier
table <- reactive(import(input$navig$datapath))
# affichage du tableau importé
output$tableau <- renderDT({
req(input$navig)
datatable(data = table(),
extensions = c("Buttons", "KeyTable"),
filter = "bottom",
options = list(dom = "Bfrtip",
buttons = c("pdf", "excel", "csv", "print")))
})
#affichage de la matrice des graphiques
output$rsg <- renderPlot({
ggpairs(table())
})
# Run the application
shinyApp(ui = ui, server = server)