hvasquez28 / g1-ds_santander-f2-team7

Repository for the team 7's R project. This group belongs to the Bedu-Santander Data Science course, Phase 2.
GNU General Public License v3.0
0 stars 0 forks source link

Creacion del dashboard #4

Open hvasquez28 opened 2 years ago

DanielT-M commented 2 years ago

Propuesta Dashboard funcionando

app.R

#install.packages("ggplot2")
#install.packages("shiny")
#install.packages("shinydashboard")
#install.packages("shinythemes")
#install.packages("dplyr")

library(ggplot2)
library(shiny)
library(shinydashboard)
library(shinythemes)
library(dplyr)

ui <- 

  fluidPage(

    dashboardPage(

      dashboardHeader(title = "Predicción de resultados", titleWidth = 300),

      dashboardSidebar(

        sidebarMenu(
          menuItem("Gráficos de barras", tabName = "Dashboard", icon = icon("bar-chart")),
          menuItem("Goles local - visitante", tabName = "goles", icon = icon("soccer-ball-o")),
          menuItem("Data table", tabName = "data_table", icon = icon("table")),
          menuItem("Factores de ganancia", tabName = "momios", icon = icon("area-chart"))

        )

      ),

      dashboardBody(

        tabItems(

          # Gráficos de barras
          tabItem(tabName = "Dashboard",
                  fluidRow(

                    titlePanel("Goles a favor y en contra por equipo"), 
                    selectInput("x", "Seleccione el valor de X",
                                choices = c("home.score", "away.score")),

                    plotOutput("plot1", height = 450, width = 750)

                  )
          ),

          # Imágenes goles local - visitante
          tabItem(tabName = "goles", 
                  fluidRow(
                    titlePanel(h3("Probabilidad de goles en casa y visitante")),

                    img(src = "anotacionesLocal.png") ,
                    img(src = "anotacionesVisitante.png"),
                    img(src = "anotacionesConjuntas.png")

                  )
          ),

          #Data Table

          tabItem(tabName = "data_table",
                  fluidRow(        
                    titlePanel(h3("Data Table")),
                    dataTableOutput ("data_table")
                  )
          ), 
          # Imágenes de factores de ganacia
          tabItem(tabName = "momios",
                  fluidRow(
                    titlePanel(h3("Gráficas de dispersión para la correlación de las variables")),
                    h3("Factor de ganancia Máximo"),
                    img( src = "momiosMaximos.png"),
                    h3("Factor de ganancia Promedio"),
                    img( src = "momiosPromedio.png")

                  )

          )

        )
      )
    )
  )

server <- function(input, output) {

  #Gráfico de barras
  output$plot1 <- renderPlot({

    macthdataURL<-"https://raw.githubusercontent.com/beduExpert/Programacion-R-Santander-2021/main/Sesion-08/Postwork/match.data.csv"
    data <-  read.csv(macthdataURL, header = T)

    data <- mutate(data, FTR = ifelse(home.score > away.score, "H", ifelse(home.score < away.score, "A", "D")))

    x <- data[,input$x]

    data %>% ggplot(aes(x, fill = FTR)) + 
      geom_bar() + 
      facet_wrap("away.team") +
      labs(x =input$x, y = "Goles") + 
      ylim(0,50)

  })

  #Data Table
  macthdataURL<-"https://raw.githubusercontent.com/beduExpert/Programacion-R-Santander-2021/main/Sesion-08/Postwork/match.data.csv"
  data <-  read.csv(macthdataURL, header = T)

  output$data_table <- renderDataTable( {data}, 
                                        options = list(aLengthMenu = c(10,20,25,40,50),
                                                       iDisplayLength = 10)
  )

}

shinyApp(ui, server)
DanielT-M commented 2 years ago

graficas para la carpeta www

anotacionesLocal.png Image

anotacionesVisitante.png Image

momiosMaximos.png Image

momiosPromedio.png Image

anotacionesConjuntas.png Image