I would like to create a shiny map using leaflet which I can publish online do that others without R can view and interact with it. I can create a shiny app using leaflet, but when I use the 'publish' button in the popup window I get an error saying 'The directory to be deployed (~) exceeds the maximum deployment size, which is 100MB. Consider creating a new directory containing only the content you wish to deploy.
I can't work out what this is telling me. Does anyone have any ideas? I have posted my code below.
library(shiny)
library(leaflet)
shinyApp(
ui = fluidPage(leafletOutput('myMap')),
server = function(input, output) {
# download and load data
map = leaflet() %>% addTiles('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png',
attribution = paste(
'© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors',
'© <a href="http://cartodb.com/attributions">CartoDB</a>'
)
) %>% setView(-122.36, 47.67, zoom = 10)
output$myMap = renderLeaflet(map)
}
)
It's a workaround but it worked for me today, when I was deploying an app myself:
When I tried to deploy a shinyApp
from inside a standard .R File
from Rstudio, I got the same error message as you when I clicked on the "Publish" button.
However when I embedded my code into a Rmarkdown
document inside a chunk, it suddenly started working.
So simply copy your code and open a new Rmarkdown file, click on "Shiny Document" and paste your code into one chunk and delete everything else but the header of the Rmarkdown file. Now when you run the code and click on "Publish", it should work.