title: How to Properly Store ShapeFiles when Deploying R Shiny App
body: <p>I am working on an R Shiny project to visualize the spread of COVID19 around the world.  When I run the app locally, it works just fine, but when I try to deploy the app, it runs into issues which I am assuming are related to storing the shapefiles:  I get an error on the map page that reads, &quot;An error has occurred. Check your logs or contact the app author for clarification.&quot;</p>
  <p>Here is my code so far:</p>
  <pre><code>#Read in datasets
  who_data &lt;- read.csv(&quot;https://covid19.who.int/WHO-COVID-19-global-data.csv&quot;)
  pops &lt;- read.csv(&quot;https://gist.githubusercontent.com/curran/0ac4077c7fc6390f5dd33bf5c06cb5ff/raw/605c54080c7a93a417a3cea93fd52e7550e76500/UN_Population_2019.csv&quot;)
  
  
  #download.file(&quot;http://thematicmapping.org/downloads/TM_WORLD_BORDERS_SIMPL-0.3.zip&quot;, destfile=&quot;world_shape_file.zip&quot;)
  #unzip(&quot;world_shape_file.zip&quot;)
  #world_spdf=readOGR(dsn = getwd(),layer = &quot;TM_WORLD_BORDERS_SIMPL-0.3&quot;)
  
  
  
  #-----Preprocessing Data-----#
  
  who_data$Date &lt;- as.Date(who_data$Date_reported)
  
  cols=colnames(pops)
  pop_data=pops[,c(cols[1],cols[length(cols)])]
  colnames(pop_data)=c(&quot;Country&quot;,&quot;Population&quot;)
  pop_data$Population=pop_data$Population*1000
  
  covid19_data=merge(x=who_data,y=pop_data,by=&quot;Country&quot;,all.x=TRUE)
  
  
  covid19_data$Date_reported=NULL
  covid19_data$Country_code=NULL
  covid19_data &lt;- covid19_data[order(covid19_data$Country,covid19_data$Date),]
  covid19_data=covid19_data[c(1,2,7,8,3,4,5,6)]
  
  
  
  
  #----- Load libraries -----#
  library(shiny)
  library(shinydashboard)
  library(DT)
  library(ggplot2)
  library(rsconnect)
  library(packrat)
  library(formattable)
  library(leaflet)
  library(leaflet.extras)
  library(rgdal)
  library(sp)
  library(raster)
  library(RColorBrewer)
  library(scales)
  library(lattice)
  library(dplyr)
  library(reshape2)
  library(plotly)
  
  
  
  # Define UI for application 
  
  
  ui &lt;- fluidPage(
      dashboardPage(
          dashboardHeader(title=&quot;COVID19 Analysis&quot;),
          dashboardSidebar(
              sidebarMenu(
                  
                  menuItem(&quot;Spread of the Virus&quot;,
                           tabName=&quot;map_spread&quot;,
                           icon=icon(&quot;viruses&quot;)
                  ))
          ),
          dashboardBody(
              tabItems(
                  
                  tabItem(
                      tabName = &quot;map_spread&quot;,
                      sliderInput(&quot;date_filter&quot;, &quot;Date Filter&quot;,
                                  min = min(covid19_data$Date), max = max(covid19_data$Date), value = min(covid19_data$Date)
                      ),
                      p(&quot;Not ready --&gt; need to clean up data&quot;),
                      leafletOutput(&quot;world_map&quot;)
                      
                  )))))
  
  # Define server logic 
  server &lt;- function(input, output) {
      
   
      #---------- WORLD MAP ----------#
      
      
      map_filter=reactive({
          filter=subset(covid19_data,Date==input$date_filter)
          return(filter)
      })
      
      
      merge_filter=reactive({
          names(world_spdf)[names(world_spdf) == &quot;NAME&quot;] &lt;- &quot;Country&quot;
          map_data=merge(x=world_spdf,y=map_filter(),by=&quot;Country&quot;,all.x=TRUE)
      })
      
      
      
      
      #Choropleth Map 
      output$world_map=renderLeaflet({
          bins=c(0,100,500,1000,5000,10000,Inf)
          pal=colorBin(palette = &quot;YlOrBr&quot;,domain = merge_filter()$Cumulative_cases,
                       na.color = &quot;transparent&quot;,
                       bins=bins)
          customLabel = paste(&quot;Country: &quot;,merge_filter()$Country,&quot;&lt;br/&gt;&quot;,
                              &quot;Cumulative cases: &quot;,merge_filter()$Cumulative_cases, serp=&quot;&quot;) %&gt;%
              lapply(htmltools::HTML)
          
          leaflet(merge_filter()) %&gt;%
              addProviderTiles(providers$OpenStreetMap,options=tileOptions(minZoom = 2,
                                                                           maxZoom = 8)) %&gt;%
              addPolygons(fillColor = ~pal(Cumulative_cases),
                          fillOpacity = 0.9,
                          stroke = TRUE,
                          color = &quot;white&quot;,
                          highlight=highlightOptions(
                              weight=5,
                              fillOpacity = 0.3
                          ),
                          label=customLabel,
                          weight=0.3,
                          smoothFactor = 0.2) %&gt;%
              
              addLegend(
                  pal=pal,
                  values = ~Cumulative_cases,
                  position = &quot;bottomright&quot;,
                  title = &quot;Cumulative cases&quot;
              )
      })
      
      
      
  }
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p>Can someone help identify the proper way to store shape files when deploying an R Shiny app?  I understand when deploying an R Shiny app using Excel files for data, I just store them in the same folder as the app.R file, but it seems these shape files are behaving in a weird way that I can't resolve.  Any help would be appreciated!  Thank you!</p>