Error deploying shiny app - works locally fails on shinyapps.io

Hi all,

This is my first post to this community. I've looked around online and been unable to find the issue to my problem. I'm trying to deploy a shiny app on shinyapps.io (I will provide the link in a comment) using the code below:

library(shiny)
library(purrr)
library(readr)
library(stringr)
library(dplyr)
library(ggplot2)
library(tidyr)
library(tibble)
library(tidyverse)
library(ggthemes)
library(viridis)
library(readxl)
library(viridisLite)

gender_data <- read_csv("gender_equality_survey.csv") %>%
  mutate(`% of respondents` = `% of respondents`*100,
         Country = ifelse(Country == "Great Britain", "UK", 
                          ifelse(Country == "United States", "USA", Country)))

world <- map_data("world") 

countries <- world %>%
  select(region) %>%
  distinct()

missing_countries_gender <- countries %>%
  filter(!(region %in% gender_data$Country)) %>%
  mutate(Male = NA,
         Female = NA,
         Total = NA) %>%
  pivot_longer(Male:Total, names_to = "Gender", values_to = "% of respondents") %>%
  rename(Country = "region")

missing_countries_question <- countries %>%
  filter(!(region %in% gender_data$Country)) %>%
  mutate(`Because women and men are not equally represented in politics` = NA,
         `Because of religion and culture that do not treat women and men as equals` = NA,
         `Because boys and girls are treated differently growing up` = NA,
         `Because women and men have different employment opportunities` = NA,
         `Because unpaid care, domestic work, and parental responsibilities are not shared equally between women and men` = NA,
         `Because women and men cannot exercise the same level of control over their bodies (for example access to contraception, delaying childbirth)` = NA,
         `Because crises (for example conflict, natural disasters, pandemics) have unequal effects on women and men` = NA,
         `Because men tend to be physically stronger than women` = NA,
         `Because girls do not receive the same access to education as boys` = NA,
         `None of these` = NA,
         `Don't know` = NA) %>%
  pivot_longer(`Because women and men are not equally represented in politics`:`Don't know`, names_to = "Response", values_to = "% of respondents") %>%
  rename(Country = "region")

missing_countries <- missing_countries_gender %>%
  full_join(missing_countries_question, by = c("Country", "% of respondents")) %>%
  mutate(`Sample Size` = 0,
         Question = unique(gender_data$Question[1]))

gender_data2 <- rbind(gender_data, missing_countries)

gender_data2 %>%
  filter(Gender == "Male",
         Response == "None of these") %>%
  ggplot(aes(map_id = Country)) +
  geom_map(aes(fill = `% of respondents`), color = "black", map = world) +
  expand_limits(x = world$long, y = world$lat) +
  scale_x_continuous(breaks = NULL) + 
  scale_y_continuous(breaks = NULL) +
  scale_fill_viridis(option = "magma") +
  labs(fill = "Percent of Respondents", x = "", y = "") +
  theme(legend.position = "bottom",
        legend.text = element_text(size = 12),
        legend.title = element_text(size = 14, hjust = 1),
        legend.key.size = unit(.5, "in"),
        panel.background = element_blank())

# Define UI for application that draws a histogram
ui <- fluidPage(
  
  # App title ----
  titlePanel("Reasons Why Women May not be Equal to Men"),
  
  # Sidebar panel for inputs ----
  sidebarLayout(
    
    sidebarPanel(
      
      selectInput(inputId = "Response", 
                  label = "Main reasons why women may not be equal to men:", 
                  choices = c("Women and men are not equally represented in politics" = "Because women and men are not equally represented in politics",
                              "Religion and culture that do not treat women and men as equals" = "Because of religion and culture that do not treat women and men as equals",
                              "Boys and girls are treated differently growing up" = "Because boys and girls are treated differently growing up",
                              "Women and men have different employment opportunities" = "Because women and men have different employment opportunities",
                              "Unpaid care, domestic work, and parental responsibilities are not shared equally between women and men" = "Because unpaid care, domestic work, and parental responsibilities are not shared equally between women and men",
                              "Women and men cannot exercise the same level of control over their bodies" = "Because women and men cannot exercise the same level of control over their bodies (for example access to contraception, delaying childbirth)",
                              "Crises effects on women and men" = "Because crises (for example conflict, natural disasters, pandemics) have unequal effects on women and men",
                              "Men tend to be physically stronger than women" = "Because men tend to be physically stronger than women",
                              "Girls do not receive the same access to education as boys" = "Because girls do not receive the same access to education as boys",
                              "None of these" = "None of these",
                              "I don't know" = "Don't know")
      ),
      
      selectInput(inputId = "Gender", 
                  label = "Survey Respondent Gender:",
                  choices = c("Female" = "Female",
                              "Male" = "Male",
                              "Total" = "Total")
      )
      
    ),
    
    # Main panel for displaying outputs ----
    mainPanel(
      
      plotOutput("world_map", height = "800px")
      
    )
    
  )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
  
  output$world_map <- renderPlot({
    
    gender_data2 %>%
      filter(Gender == input$Gender,
             Response == input$Response) %>%
      ggplot(aes(map_id = Country)) +
      geom_map(aes(fill = `% of respondents`), color = "black", map = world) +
      expand_limits(x = world$long, y = world$lat) +
      scale_x_continuous(breaks = NULL) + 
      scale_y_continuous(breaks = NULL) +
      scale_fill_viridis(option = "plasma") +
      labs(fill = "Percent of respondents: ", x = "", y = "") +
      theme(legend.position = "bottom",
            legend.text = element_text(size = 12),
            legend.title = element_text(size = 14, hjust = 1),
            legend.key.size = unit(.5, "in"),
            panel.background = element_blank())
    
  })
}


shinyApp(ui = ui, server = server)

The code works when I run it locally and when I open it locally in the browser. Here are the relevant logs from my app deployment:

022-04-01T17:50:59.363992+00:00 shinyapps[5993086]: Error in value[[3L]](cond) : 
2022-04-01T17:50:59.364023+00:00 shinyapps[5993086]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
2022-04-01T17:50:59.364100+00:00 shinyapps[5993086]: Execution halted
2022-04-01T17:50:59.364142+00:00 shinyapps[5993086]: Shiny application exiting ...

I have no idea what "Error in value[3L] : " means and how I can fix it. I very much appreciate your help. If there's anything else I can provide to get an answer please let me know.

Link to my app: https://kc57oc-zach.shinyapps.io/gender_equality3/

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Additionally, I could recommend adding additional logging into your app.
I think using CRAN - Package logger can be very useful.