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?

Thank you!

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", 
                                                    tabName = "Informe_Tipo", 
                                                    icon = icon("futbol"))))),
  dashboardBody(
    tabItems(
      tabItem(tabName = "Informe_Tipo",
              h1("INFORME TIPO"),
              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 = "Competicion_1",
                                       label = "Competición: ",
                                       choices = c("Bundesliga 2", "Championship", "Liga Smartbank", "Ligue 2", 
                                                   "Serie B")),
                           selectInput(inputId = "Equipo_1",
                                       label = "Equipo: ",
                                       choices = c("Jahn Regensburg", "Dynamo Dresden", "Nürnberg", "Ingolstadt", 
                                                   "Hamburger SV", "Fortuna Düsseldorf", "Holstein Kiel", "Paderborn", 
                                                   "Werder Bremen", "Heidenheim", "Darmstadt 98", "Schalke 04", 
                                                   "Karlsruher SC", "Hannover 96", "Hansa Rostock", "Erzgebirge Aue", 
                                                   "Sandhausen", "St, Pauli", "Nürnberg II", "Hatayspor", "Borussia Dortmund II", 
                                                   "Werder Bremen U19", "Fortuna Düsseldorf II", "Schalke 04 II", 
                                                   "Apollon Smirnis", "Hamburger SV U19", "Karlsruher SC U17", "Antwerp", 
                                                   "Hallescher FC", "Union Berlin", "Freiburg", "Holstein Kiel II", 
                                                   "Darmstadt 98 U19", "Verl", "Arminia Bielefeld", "Karlsruher SC U19", 
                                                   "Vissel Kobe", "Werder Bremen II", "Norwich City", "Schalke 04 U19", 
                                                   "Ingolstadt U19", "Waldhof Mannheim", "Hannover 96 II", "Mallorca", 
                                                   "Sheffield United", "Swansea City", "West Bromwich Albion", "Blackburn Rovers", 
                                                   "Arsenal", "Cardiff City", "Millwall", "Barnsley", "Nottingham Forest", 
                                                   "Coventry City", "Blackpool", "Peterborough United", "Birmingham City", 
                                                   "Bristol City", "Preston North End", "Queens Park Rangers", "Hull City", 
                                                   "Luton Town", "Stoke City U23", "Stoke City", "Middlesbrough", 
                                                   "Reading", "Derby County", "Middlesbrough U23", "Huddersfield Town", 
                                                   "Reading U23", "Fulham", "Bournemouth", "Birmingham City U23", 
                                                   "Swindon Town", "Derby County U23", "Portsmouth", "Guiseley", 
                                                   "Sheffield United U23", "Cardiff City U23", "Northampton Town", 
                                                   "Hearts", "Club Brugge", "Chelsea U23", "Nottingham Forest U23", 
                                                   "Notts County", "West Bromwich Albion U23", "Barnsley U23", "Napoli", 
                                                   "PAOK", "Grimsby Town", "Cesena", "Derby County U18", "Fleetwood Town", 
                                                   "Accrington Stanley", "Fulham U23", "Hull City U18", "Huddersfield Town B", 
                                                   "Olympiacos Piraeus", "Lincoln City", "Coventry City U23", "Ipswich Town", 
                                                   "Shrewsbury Town", "Cheltenham Town", "Swansea City U18", "Portimonense", 
                                                   "Charlton Athletic", "Hibernian", "Bristol City U23", "Millwall U23", 
                                                   "Hull City U23", "Aris", "Gillingham", "Pisa", "Blackburn Rovers U23", 
                                                   "Preston North End U18", "Oxford United", "Sheffield United U18", 
                                                   "Millwall U18", "Ponferradina", "Girona", "Ibiza", "Burgos", 
                                                   "Brentford", "Real Zaragoza", "Las Palmas", "Eibar", "Real Sociedad B", 
                                                   "Huesca", "Leganés", "Alcorcón", "Málaga", "Fuenlabrada", "Sporting Gijón", 
                                                   "Almería", "Lugo", "Real Oviedo", "Real Valladolid", "Tenerife", 
                                                   "Cartagena", "Amorebieta", "Mirandés", "Real Sociedad", "Real Sociedad III", 
                                                   "Las Palmas Atlético", "CD Calahorra", NA, "Sporting Gijón B", 
                                                   "Tenerife B", "Cartagena B", "Girona II", "Valladolid Promesas", 
                                                   "Getafe", "Real Oviedo Vetusta", "Málaga CF U17", "Alcorcón B", 
                                                   "Racing Santander", "Fuenlabrada B", "Cádiz", "Elche", "Leganés B", 
                                                   "Huesca B", "Dnipro-1", "Charlotte Independence", "Deportivo Alavés", 
                                                   "Valencia", "Real Zaragoza B", "Barcelona", "Mirandés B", "Sabadell", 
                                                   "Dunkerque", "Pau", "Young Boys", "Ajaccio", "Grenoble", "Dijon", 
                                                   "Nancy", "Auxerre", "Guingamp", "Paris", "Bastia", "Valenciennes", 
                                                   "Nîmes", "Rodez ", "Toulouse", "Nancy II", "Le Havre", "Sochaux", 
                                                   "Niort", "Quevilly Rouen", "Amiens SC", "Caen", "Guingamp II", 
                                                   "Le Havre U19", "Nîmes II", "Rizespor", "Dijon U19", "Lecce", 
                                                   "Caen II", "Brescia", "Lech Poznan", "Besiktas", "Parma", "Paris II", 
                                                   "Famalicão", "Dunkerque II", "Manisa BBSK", "Niort II", "Kayserispor", 
                                                   "Ajaccio U19", "Quevilly Rouen II", "Dijon II", "Paris U19", 
                                                   "Bayer Leverkusen", "Le Havre U17", "Nancy U18", "Paris U17", 
                                                   "Spezia", "Warta Poznan", "Montpellier", "Valenciennes U19", 
                                                   "U Craiova 1948", "Valenciennes II", "Sochaux U19", "Cosenza", 
                                                   "Ternana", "Reggina", "Benevento", "SPAL", "Alessandria", "Como", 
                                                   "Ascoli", "Cittadella", "Monza", "Frosinone", "Pordenone", "Crotone", 
                                                   "Perugia", "Cremonese", "Vicenza", "Parma U19", "Renate", "Frosinone U19", 
                                                   "Vålerenga", "ACN Siena", "Reggina U17", "Carrarese", "Salernitana", 
                                                   "Imolese", "SPAL U19", "Pordenone U17", "Pisa U19", "Triestina", 
                                                   "Pordenone U19", "Yeni Malatyaspor", "FeralpiSalò", "Vicenza U19", 
                                                   "Alessandria U19", "Reggina U19", "Empoli", "Ascoli U19", "Crotone U19", 
                                                   "Cosenza U19", "Benevento U19")),
                           selectInput(inputId = "Demarcación_1",
                                       label = "Demarcación: ",
                                       choices = c("Portero", "Central", "Lateral", "Mediocentro", "Extremo", 
                                                   "Delantero")),
                           selectInput(inputId = "Nacionalidad_1",
                                       label = "Nacionalidad: ",
                                       choices = c("Germany", "Russia", "Austria", "Czech Republic", "Denmark", 
                                                   "Sweden", "Bosnia and Herzegovina", "Poland", "Spain", "United States", 
                                                   "Romania", "Finland", "Belgium", "France", "Switzerland", "England", 
                                                   "Croatia", "Japan", "Slovenia", "Norway", "Mexico", "Serbia", 
                                                   "Senegal", "Canada", "North Macedonia", "Georgia", "Nigeria", 
                                                   "Brazil", "Netherlands", "Kosovo", "Curaçao", "Ghana", "Azerbaijan", 
                                                   "Korea Republic", "Cameroon", "Dominican Republic", "Bulgaria", 
                                                   "Australia", "Albania", "Luxembourg", "Slovakia", "Italy", "Iceland", 
                                                   "Gambia", "Ukraine", "Sierra Leone", "Côte d&#39;Ivoire", "Congo DR", 
                                                   "New Zealand", "Sudan", "Guinea", "Congo", "Wales", "Scotland", 
                                                   "Estonia", "Montenegro", "Republic of Ireland", "Argentina", 
                                                   "Northern Ireland", "Portugal", "Saudi Arabia", "Namibia", "Iran", 
                                                   "Paraguay", "Jamaica", "Guinea-Bissau", "Colombia", "Kenya", 
                                                   "Cuba", "Angola", "Bermuda", "Ecuador", "Uruguay", "Morocco", 
                                                   "Equatorial Guinea", "Venezuela", "Peru", "Panama", "Mali", "Egypt", 
                                                   "Israel", "French Guiana", "Benin", "Gabon", "Cape Verde Islands", 
                                                   "Guadeloupe", "Tunisia", "Haiti", "Comoros", "Réunion", "Martinique", 
                                                   "Algeria", "Turkey", "South Africa", "Burkina Faso", "New Caledonia", 
                                                   "Togo", "Zambia", "Lithuania", "Greece", "Hungary", "Uganda", 
                                                   "Cyprus", "Moldova", "Madagascar", "Malta", "Chile", "Honduras", 
                                                   "Latvia")),
                           selectInput(inputId = "Pie_Dominante_1",
                                       label = "Pie Dominante: ",
                                       choices = c("derecho", "izquierdo", "ambidiestro", NA, "unknown")),
                           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 = c("Portero", "Central", "Lateral", "Mediocentro", "Extremo", 
                                                   "Delantero"),
                                       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)```

Cross posted here

library(shiny)

(myglobal <<- data.frame(
  x1 = character(0)
))

ui <- fluidPage(
  selectInput("x1","pick something",choices = letters[1:3],selected = "a"),
  actionButton("submit","to global"),
  tableOutput("view_of_myglobal")
)

server <- function(input, output, session) {
  
  observeEvent(input$submit,
               {
                 newpart <- data.frame(x1=input$x1)
                 
          
                 myglobal <<- bind_rows(myglobal,
                           newpart)
                           
               })
  
  output$view_of_myglobal <- renderTable({
    input$submit
    myglobal
  })
}

shinyApp(ui, server)
1 Like