Kaihua Hou
Kaihua Hou

Reputation: 89

Shiny.io cannot deploy the application

I was trying to create an interactive map with the Shiny web application, however, after I published it to my shiny.io account, clicking the URL will only yield: shiny.io application page

An error has occurred!

An error has occurred. Check your logs or contact the app author for clarification.

Can you help me with it? Thanks!

Here are the logs of the application:

2020-07-28T20:32:42.887039+00:00 shinyapps[2621249]: jsonlite version: 1.6.1
2020-07-28T20:32:42.887039+00:00 shinyapps[2621249]: RJSONIO version: (none)
2020-07-28T20:32:42.887050+00:00 shinyapps[2621249]: htmltools version: 0.5.0
2020-07-28T20:32:42.887235+00:00 shinyapps[2621249]: Using pandoc: /opt/connect/ext/pandoc2
2020-07-28T20:32:43.039412+00:00 shinyapps[2621249]: 
2020-07-28T20:32:43.039413+00:00 shinyapps[2621249]: Starting R with process ID: '58'
2020-07-28T20:32:43.106062+00:00 shinyapps[2621249]: Listening on http://127.0.0.1:36754
2020-07-28T20:32:43.106061+00:00 shinyapps[2621249]: 
2020-07-28T20:32:43.035592+00:00 shinyapps[2621249]: Using jsonlite for JSON processing
2020-07-28T20:32:43.299242+00:00 shinyapps[2621249]: Warning: Error in plotlyOutput: could not find function "plotlyOutput"
2020-07-28T20:32:43.304719+00:00 shinyapps[2621249]:    99: div
2020-07-28T20:32:43.304717+00:00 shinyapps[2621249]:   100: dots_list
2020-07-28T20:32:43.304719+00:00 shinyapps[2621249]:    98: tabPanel
2020-07-28T20:53:57.079846+00:00 shinyapps[2621249]: Running on host: 220810008dc5
2020-07-28T20:53:57.085768+00:00 shinyapps[2621249]: Server version: 1.8.4-11
2020-07-28T20:53:57.085785+00:00 shinyapps[2621249]: LANG: en_US.UTF-8
2020-07-28T20:53:57.085827+00:00 shinyapps[2621249]: R version: 4.0.0
2020-07-28T20:53:57.085867+00:00 shinyapps[2621249]: shiny version: 1.5.0
2020-07-28T20:53:57.085869+00:00 shinyapps[2621249]: httpuv version: 1.5.4
2020-07-28T20:53:57.085881+00:00 shinyapps[2621249]: rmarkdown version: (none)
2020-07-28T20:53:57.085882+00:00 shinyapps[2621249]: knitr version: (none)
2020-07-28T20:53:57.085895+00:00 shinyapps[2621249]: jsonlite version: 1.6.1
2020-07-28T20:53:57.085909+00:00 shinyapps[2621249]: RJSONIO version: (none)
2020-07-28T20:53:57.085959+00:00 shinyapps[2621249]: htmltools version: 0.5.0
2020-07-28T20:53:57.086171+00:00 shinyapps[2621249]: Using pandoc: /opt/connect/ext/pandoc2
2020-07-28T20:53:57.244930+00:00 shinyapps[2621249]: Using jsonlite for JSON processing
2020-07-28T20:53:57.248899+00:00 shinyapps[2621249]: 
2020-07-28T20:53:57.248900+00:00 shinyapps[2621249]: Starting R with process ID: '24'
2020-07-28T20:53:57.319981+00:00 shinyapps[2621249]: 
2020-07-28T20:53:57.319982+00:00 shinyapps[2621249]: Listening on http://127.0.0.1:44567
2020-07-28T20:56:14.943220+00:00 shinyapps[2621249]: Running on host: 220810008dc5
2020-07-28T20:56:14.950036+00:00 shinyapps[2621249]: Server version: 1.8.4-11
2020-07-28T20:56:14.950099+00:00 shinyapps[2621249]: httpuv version: 1.5.4
2020-07-28T20:56:14.950046+00:00 shinyapps[2621249]: LANG: en_US.UTF-8
2020-07-28T20:56:14.950063+00:00 shinyapps[2621249]: R version: 4.0.0
2020-07-28T20:56:14.950165+00:00 shinyapps[2621249]: knitr version: (none)
2020-07-28T20:56:14.950089+00:00 shinyapps[2621249]: shiny version: 1.5.0
2020-07-28T20:56:14.950105+00:00 shinyapps[2621249]: rmarkdown version: (none)
2020-07-28T20:56:14.950182+00:00 shinyapps[2621249]: jsonlite version: 1.6.1
2020-07-28T20:56:14.950410+00:00 shinyapps[2621249]: Using pandoc: /opt/connect/ext/pandoc2
2020-07-28T20:56:15.113622+00:00 shinyapps[2621249]: Using jsonlite for JSON processing
2020-07-28T20:56:14.950182+00:00 shinyapps[2621249]: RJSONIO version: (none)
2020-07-28T20:56:14.950183+00:00 shinyapps[2621249]: htmltools version: 0.5.0
2020-07-28T20:56:15.118668+00:00 shinyapps[2621249]: Starting R with process ID: '73'
2020-07-28T20:56:15.118666+00:00 shinyapps[2621249]: 
2020-07-28T20:56:15.192554+00:00 shinyapps[2621249]: 
2020-07-28T20:56:15.192556+00:00 shinyapps[2621249]: Listening on http://127.0.0.1:37222
2020-07-28T20:56:15.320813+00:00 shinyapps[2621249]: Warning: Error in plotlyOutput: could not find function "plotlyOutput"
2020-07-28T20:56:15.326689+00:00 shinyapps[2621249]:   100: dots_list
2020-07-28T20:56:15.326691+00:00 shinyapps[2621249]:    99: div
2020-07-28T20:56:15.326692+00:00 shinyapps[2621249]:    98: tabPanel

It worked perfectly in RStudio with the following ui.R and Server.R:

library(shiny)
library(leaflet)

shinyUI(fluidPage(
    
    titlePanel("JHU COVID-19 Modeling Visualization Map"),
    
    sidebarLayout(
        sidebarPanel(
            checkboxGroupInput("statesInput", "Choose the State(s)", 
                               c("AL", "MO", "AK", "MT", "AZ", "NE", 
                                 "AR", "NV", "CA", "NH", "CO", "NJ", 
                                 "CT", "NM", "DE", "NY", "DC", "NC", 
                                 "FL", "ND", "GA", "OH", "HI", "OK", 
                                 "ID", "OR", "IL", "PA", "IN", "RI", 
                                 "IA", "SC", "KS", "SD", "KY", "TN", 
                                 "LA", "TX", "ME", "UT", "MD", "VT", 
                                 "MA", "VA", "MI", "WA", "MN", "WV", 
                                 "MS", "WI", "WY"),
                               inline = TRUE),
                                                                       
            submitButton("Submit"),
                ), 

        mainPanel(
            tabsetPanel(type = "tabs", 
                        tabPanel("County Level", plotlyOutput("countyPolygonMap")), 
                        tabPanel("State Level", leafletOutput("statePolygonMap"))
            )
        )
)))

library(shiny)
library(leaflet)
library(magrittr)
library(rgdal)

shinyServer(function(input, output) {
    library(rjson)
    library(plotly)
    library(dplyr)
    
    statepolygonZip <- download.file("https://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_state_500k.zip", 
                                     destfile = "cb_2018_us_state_500k.zip");
    unzip("cb_2018_us_state_500k.zip");
    statePolygonData <- readOGR("cb_2018_us_state_500k.shp", layer = "cb_2018_us_state_500k", 
                                GDAL1_integer64_policy = TRUE);
    ## obtaning the state shape file data provided by cencus.gov 
    ## for more categories of region shape file: 
    ## https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html
    
    
    output$countyPolygonMap <- renderPlotly({
        url <- 'https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json'
        countyGeo <- rjson::fromJSON(file=url)
        ## Obtaining the geographical file for all U.S. counties
        url2<- "https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv"
        df <- read.csv(url2, colClasses=c(fips="character"))
        names(df)[2] = "unemployment"
        ## obtaining the unemployment rate data 
        url3 <- "https://storage.googleapis.com/kagglesdsdata/datasets%2F579969%2F1374720%2Fus_county.csv?GoogleAccessId=gcp-kaggle-com@kaggle-161607.iam.gserviceaccount.com&Expires=1596139521&Signature=easqHBFZ757D%2F7LVyDM%2BF%2FIMU6l2OEY6giqVvIC0l0tSSe%2Fohq6NC%2FLFKbsIV6FdFALmPUqG9vATbg0cuRVVwGQMsoUOjlW%2BZLhTVluxbYh1dDE1MTFzWRpzlSH18ejIwqa61F0ARJ%2Bpq6ryIfJuE7wQQ1rOCEpaVB9m%2FP7QaZm2gBJeHYLXJXcvO8w1p0sEnqRsGAesg2Fgj%2Bv8unPGNtDJekEWuNbl1K9k7CAaZWjG2QQ94LB9tAPvfKqykDWDD7w6yN3YFkcfu7kUmjs0CybnMD6IP%2FM5hvJXuUTIie0MOMTWt5bIua4qcTHxIxR5l918y1H17JA2HHrnKLVY%2BA%3D%3D"
        county <- read.csv(url3)
        county$nfips <- sprintf("%05d",county$fips)

        countyPolygonMap <- plot_ly() %>% add_trace(
            type="choroplethmapbox",
            geojson=countyGeo,
            locations=county$nfips,
            z=~county$population,
            colorscale="Viridis",
            zmin=200,
            zmax=1100000,
            marker=list(line=list(width=0),opacity=0.5)
        ) %>% layout(
            mapbox=list(
                style="carto-positron",
                zoom =2,
                center=list(lon= -95.71, lat=37.09))
        );
        countyPolygonMap;
        ## generating the interactive plotly map
    })
    
    output$statePolygonMap <-renderLeaflet ({
        statesAbbr <- subset(statePolygonData, input$statesInput %in% statePolygonData$STUSPS);
        ## subsetting the shape file with the selected states
        
        leaflet(statesAbbr) %>%
            addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
                        opacity = 1.0, fillOpacity = 0.5,
                        fillColor = ~colorQuantile("YlOrRd", ALAND)(ALAND),
                        highlightOptions = highlightOptions
                        (color = "white", weight = 2,bringToFront = TRUE))
    })
    ## producing the map with polygon boundary on the state level
})

Upvotes: 1

Views: 441

Answers (2)

Daniel_j_iii
Daniel_j_iii

Reputation: 3242

Can you verify you have plotly installed for this app, also check your plotlyOutput function in your app, which is where your application threw an error

library(plotly)

Upvotes: 2

itsMeInMiami
itsMeInMiami

Reputation: 2669

I am thinking you mean shinyapps.io. To get to the logs:

  1. Click on the dashboard view (the left-side panel).
  2. Click on the name of your app (a hyperlink)
  3. Click on the logs button at the top of the screen

Upvotes: 1

Related Questions