r - Shiny.io 无法部署应用程序
问题描述
我试图使用 Shiny 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
})
解决方案
您能否验证您已plotly
为此应用程序安装,还检查您的应用程序中的plotlyOutput
功能,这是您的应用程序抛出错误的地方
library(plotly)
推荐阅读
- spring - 如何从自定义源加载 Spring Boot 中的属性?
- bash - 使用分隔符循环字符串(键,值) - Bash 脚本
- git - make 命令构建 vivado 项目后出错
- rust - 是否可以在纯 Rust 宏中编写像 `print!` 这样复杂的东西?
- c - “字符串”声明的 gcc 数组失败
- javascript - 错误:无法在“节点”上执行“appendChild”:文档上只允许一个元素
- ios - SpriteKit Swift:SKView 返回 nil
- asp.net-web-api - Web API Post Type 操作没有被 jquery ajax 调用
- python - 简单标题的 Django 匹配 URL
- swift - 快速加载嵌套的xib