我试图创建一个与闪亮的web应用程序交互的地图,但是,当我将它发布到我的shiny.io帐户后,单击URL只会产生:shiny.io应用程序页面
An error has occurred!
An error has occurred. Check your logs or contact the app author for clarification.
你能帮我吗?谢谢!
下面是应用程序的日志:
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
它在RStudio中与以下ui.R和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
})
发布于 2020-07-28 21:21:57
你能确认你已经为这个应用程序安装了plotly
吗?也可以在应用程序中检查你的plotlyOutput
函数,这是你的应用程序抛出错误的地方。
library(plotly)
发布于 2020-07-28 21:15:43
我想你是说shinyapps.io。要找到原木:
https://stackoverflow.com/questions/63142711
复制相似问题