shiny – How can I store/transfer information from my ShinyApp to a dataframe in my global environment via an action button?

good afternoon,

I am a beginner creating ShinyApps and I would really appreciate if someone could help me to solve the following problem:

The purpose of the App is to store the information that a football scout fills on the reports.

Every time a scout fills out the different items of the report, I would like to store/transfer this information in a new dataframe on my global environment in R Studio via the action button below called “Guardar”. Any idea?

library(shinyWidgets)
library(shinydashboard)
library(shinyauthr)
library(shinyjs)
library(sodium)
library(tibble)
library(dplyr)
library(DT)

#----------UI----------

ui <- dashboardPage(title = "Herramienta Scouting TFM", skin = "blue",
                    dashboardHeader(title = "Herramienta Scouting TFM", 
                                    titleWidth = "300px"),
                    
                    dashboardSidebar(width = "300px",
                                     sidebarMenu(menuItem(text = "Informe Tipo", icon = icon(name =  "file-contract", lib = "font-awesome"),
                                                          menuSubItem("Informe Portero", tabName = "Informe_Portero", icon = icon("futbol"))),
                                                 menuItem(text = "BBDD de Informes", icon = icon("database", lib = "font-awesome"),
                                                          dateInput(inputId = "Fecha_Informe", 
                                                                    label = "Fecha de Realización del Informe: ", 
                                                                    value = Sys.Date(), 
                                                                    weekstart = 1, 
                                                                    language = "es"),
                                                          pickerInput(inputId = "Competición", 
                                                                      label = "Competición: ", 
                                                                      choices = competiciones,
                                                                      selected = character(0),
                                                                      multiple = TRUE,
                                                                      options = list(`actions-box` = TRUE)),
                                                          pickerInput(inputId = "Equipo",
                                                                      label = "Equipo: ", 
                                                                      choices = equipos,
                                                                      selected = character(0),
                                                                      multiple = TRUE,
                                                                      options = list(`actions-box` = TRUE)),
                                                          pickerInput(inputId = "Demarcación",
                                                                      label = "Demarcación: ",
                                                                      choices = demarcaciones,
                                                                      selected = character(0),
                                                                      multiple = TRUE,
                                                                      options = list(`actions-box` = TRUE)),
                                                          pickerInput(inputId = "Nacionalidad",
                                                                      label = "Nacionalidad: ",
                                                                      choices = nacionalidades,
                                                                      selected = character(0),
                                                                      multiple = TRUE,
                                                                      options = list(`actions-box` = TRUE)),
                                                          pickerInput(inputId = "Pie_Dominante",
                                                                      label = "Pie Dominante: ",
                                                                      choices = pie_dominante,
                                                                      selected = character(0),
                                                                      multiple = TRUE,
                                                                      options = list(`actions-box` = TRUE)),
                                                          pickerInput(inputId = "Jugador",
                                                                      label = "Jugador: ",
                                                                      choices = jugadores,
                                                                      selected = character(0),
                                                                      multiple = TRUE,
                                                                      options = list(`actions-box` = TRUE)),
                                                          sliderInput(inputId = "Edad", 
                                                                      label = "Edad: ", 
                                                                      min = 15, 
                                                                      max = 40,
                                                                      value = c(15,40),
                                                                      ticks = FALSE),
                                                          sliderInput(inputId = "Minutos_Jugados",
                                                                      label = "Minutos Jugados: ",
                                                                      min = 0,
                                                                      max = 4000,
                                                                      value = c(0, 4000),
                                                                      ticks = FALSE),
                                                          sliderInput(inputId = "Valor_Mercado",
                                                                      label = "Valor de Mercado: ",
                                                                      min = 0,
                                                                      max = 50000000,
                                                                      value = c(0, 50000000),
                                                                      ticks = FALSE),
                                                          dateRangeInput(inputId = "Finalización_Contrato",
                                                                         label = "Fecha de Finalización de Contrato: ",
                                                                         start = Sys.Date(),
                                                                         end = Sys.Date()+365,
                                                                         min = Sys.Date(),
                                                                         weekstart = 1,
                                                                         language = "es",
                                                                         separator = "a")),
                                                 menuItem(text = "Estadísticas de Jugadores", icon = icon("chart-line", lib = "font-awesome")))),
                    
                    dashboardBody(
                      tabItems(
                        tabItem(tabName = "Informe_Portero",
                                h1("INFORME PORTERO"),
                                br(),
                                fluidRow(
                                  column(width = 4,
                                         box(title = "INFORMACIÓN DEL SCOUT ",
                                             background = "light-blue",
                                             width = 12),
                                         box(status = "primary",
                                             width = 12,
                                             textInput(inputId = "Scout_1",
                                                       label = "Nombre Completo: ",
                                                       value = character(0)),
                                             dateInput(inputId = "Fecha_Informe_1",
                                                       label = "Fecha de Realización del Informe: ",
                                                       value = Sys.Date(),
                                                       min = Sys.Date(),
                                                       max = Sys.Date(),
                                                       weekstart = 1,
                                                       language = "es")),
                                         box(title = "INFORMACIÓN DEL JUGADOR ",
                                             background = "light-blue",
                                             width = 12),
                                         box(status = "primary",
                                             width = 12,
                                             selectInput(inputId = "Competición_1",
                                                         label = "Competición: ",
                                                         choices = competiciones),
                                             selectInput(inputId = "Equipo_1",
                                                         label = "Equipo: ",
                                                         choices = equipos),
                                             selectInput(inputId = "Demarcación_1",
                                                         label = "Demarcación: ",
                                                         choices = c("Portero")),
                                             selectInput(inputId = "Nacionalidad_1",
                                                         label = "Nacionalidad: ",
                                                         choices = nacionalidades),
                                             selectInput(inputId = "Pie_Dominante_1",
                                                         label = "Pie Dominante: ",
                                                         choices = pie_dominante),
                                             selectInput(inputId = "Jugador_1",
                                                         label = "Jugador: ",
                                                         choices = jugadores),
                                             sliderInput(inputId = "Edad_1",
                                                         label = "Edad: ",
                                                         min = 15,
                                                         max = 40,
                                                         value = 15,
                                                         ticks = FALSE)),
                                         box(title = "INFORMACIÓN DEL PARTIDO ",
                                             background = "light-blue",
                                             width = 12),
                                         box(status = "primary",
                                             width = 12,
                                             textInput(inputId = "Partido_1",
                                                       label = "Partido (Equipo Local) (X) - (X) (Equipo Visitante): ",
                                                       value = character(0)),
                                             pickerInput(inputId = "Demarcación_Partido_1",
                                                         label = "Demarcación en el Partido: ",
                                                         choices = demarcaciones,
                                                         selected = character(0),
                                                         multiple = TRUE,
                                                         options = list(`actions-box` = TRUE)),
                                             sliderInput(inputId = "Minutos_Partido_1",
                                                         label = "Minutos Jugados: ",
                                                         min = 0,
                                                         max = 90,
                                                         value = 0,
                                                         ticks = FALSE))),
                                  column(width = 8,
                                         box(title = "VALORACIÓN DE LOS ÍTEMS ",
                                             background = "light-blue",
                                             width = 12),
                                         box(title = "Capacidad de jugar con los pies: ",
                                             status = "primary",
                                             width = 12,
                                             radioGroupButtons(inputId = "1_Valoración_1",
                                                               label = "Valoración: ",
                                                               choices = c("1", "2", "3", "4"),
                                                               selected = character(0),
                                                               status = "primary",
                                                               justified = TRUE),
                                             textInput(inputId = "1_Comentario_1",
                                                       label = "Comentarios: ")),
                                         box(title = "Capacidad de salida en balones divididos: ",
                                             status = "primary",
                                             width = 12,
                                             radioGroupButtons(inputId = "1_Valoración_2",
                                                               label = "Valoración: ",
                                                               choices = c("1", "2", "3", "4"),
                                                               selected = character(0),
                                                               status = "primary",
                                                               justified = TRUE),
                                             textInput(inputId = "1_Comentario_2",
                                                       label = "Comentarios: ")),
                                         box(title = "Reflejos: ",
                                             status = "primary",
                                             width = 12,
                                             radioGroupButtons(inputId = "1_Valoración_3",
                                                               label = "Valoración: ",
                                                               choices = c("1", "2", "3", "4"),
                                                               selected = character(0),
                                                               status = "primary",
                                                               justified = TRUE),
                                             textInput(inputId = "1_Comentario_3",
                                                       label = "Comentarios: ")),
                                         box(title = "Dominio del juego aéreo: ",
                                             status = "primary",
                                             width = 12,
                                             radioGroupButtons(inputId = "1_Valoración_4",
                                                               label = "Valoración: ",
                                                               choices = c("1", "2", "3", "4"),
                                                               selected = character(0),
                                                               status = "primary",
                                                               justified = TRUE),
                                             textInput(inputId = "1_Comentario_4",
                                                       label = "Comentarios: ")),
                                         box(title = "Capacidad de comunicación: ",
                                             status = "primary",
                                             width = 12,
                                             radioGroupButtons(inputId = "1_Valoración_5",
                                                               label = "Valoración: ",
                                                               choices = c("1", "2", "3", "4"),
                                                               selected = character(0),
                                                               status = "primary",
                                                               justified = TRUE),
                                             textInput(inputId = "1_Comentario_5",
                                                       label = "Comentarios: ")))),
                                actionBttn(inputId = "boton", 
                                           label = "Guardar", 
                                           icon = icon("save", lib = "font-awesome"), 
                                           style = "jelly", 
                                           color = "primary", 
                                           size = "md")))
                    )
)

#----------SERVER----------

server <- function(input, output){}

#----------SHINYAPP----------

shinyApp(ui, server)```

Thank you!

Leave a Comment