繁体   English   中英

我的 Shiny 应用程序可以在本地工作,但不能在 shinyapps.io 上工作

[英]My Shiny App works locally but not on shinyapps.io

我构建了一个简单的 shiny 应用程序。 它在本地运行良好,但是当我将其加载到 shinyapps.io 时出现错误。

这是错误消息:

发生了错误。 发生了错误。 检查您的日志或联系应用作者进行澄清。

这是日志中的 output。

> rsconnect::showLogs(appName="vaccines-by-country",streaming=TRUE) 
2021-05-25T11:12:17.576509+00:00 shinyapps[4164097]: Registered S3 methods overwritten by 'tibble':
        2021-05-25T11:12:17.576512+00:00 shinyapps[4164097]:   method     from  
2021-05-25T11:12:17.679447+00:00 shinyapps[4164097]:     filter, lag
2021-05-25T11:12:17.576512+00:00 shinyapps[4164097]:   format.tbl pillar
2021-05-25T11:12:17.679448+00:00 shinyapps[4164097]: 
        2021-05-25T11:12:17.576512+00:00 shinyapps[4164097]:   print.tbl  pillar
2021-05-25T11:12:17.679812+00:00 shinyapps[4164097]: The following objects are masked from ‘package:base’:
        2021-05-25T11:12:17.678697+00:00 shinyapps[4164097]: 
        2021-05-25T11:12:17.679814+00:00 shinyapps[4164097]: 
        2021-05-25T11:12:17.678700+00:00 shinyapps[4164097]: Attaching package: ‘dplyr’
2021-05-25T11:12:17.679447+00:00 shinyapps[4164097]: 
        2021-05-25T11:12:17.678701+00:00 shinyapps[4164097]: 
        2021-05-25T11:12:17.679446+00:00 shinyapps[4164097]: The following objects are masked from ‘package:stats’:
        2021-05-25T11:12:17.679812+00:00 shinyapps[4164097]: 
        2021-05-25T11:12:17.679813+00:00 shinyapps[4164097]:     intersect, setdiff, setequal, union
2021-05-25T11:12:17.872130+00:00 shinyapps[4164097]:   88: <Anonymous>
        2021-05-25T11:12:17.863510+00:00 shinyapps[4164097]: Warning: Error in <Anonymous>: error reading from the connection
2021-05-25T11:15:32.272140+00:00 shinyapps[4164097]: Running on host: 16ba9f6b9d17
2021-05-25T11:15:32.276813+00:00 shinyapps[4164097]: R version: 4.0.2
2021-05-25T11:15:32.276812+00:00 shinyapps[4164097]: LANG: en_US.UTF-8
2021-05-25T11:15:32.276832+00:00 shinyapps[4164097]: shiny version: 1.5.0
2021-05-25T11:15:32.276800+00:00 shinyapps[4164097]: Server version: 1.8.6.1
2021-05-25T11:15:32.276876+00:00 shinyapps[4164097]: rmarkdown version: (none)
2021-05-25T11:15:32.276911+00:00 shinyapps[4164097]: knitr version: (none)
2021-05-25T11:15:32.276918+00:00 shinyapps[4164097]: jsonlite version: 1.7.1
2021-05-25T11:15:32.276942+00:00 shinyapps[4164097]: htmltools version: 0.5.1.1
2021-05-25T11:15:32.277087+00:00 shinyapps[4164097]: Using pandoc: /opt/connect/ext/pandoc/2.11
2021-05-25T11:15:32.276869+00:00 shinyapps[4164097]: httpuv version: 1.5.5
2021-05-25T11:15:32.434697+00:00 shinyapps[4164097]: Using jsonlite for JSON processing
2021-05-25T11:15:32.276919+00:00 shinyapps[4164097]: RJSONIO version: (none)
2021-05-25T11:15:32.437887+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:32.437888+00:00 shinyapps[4164097]: Starting R with process ID: '26'
2021-05-25T11:15:32.462208+00:00 shinyapps[4164097]: Listening on http://127.0.0.1:46118
2021-05-25T11:15:32.462207+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:43.997554+00:00 shinyapps[4164097]: Registered S3 methods overwritten by 'tibble':
        2021-05-25T11:15:43.997556+00:00 shinyapps[4164097]:   method     from  
2021-05-25T11:15:43.997556+00:00 shinyapps[4164097]:   format.tbl pillar
2021-05-25T11:15:43.997557+00:00 shinyapps[4164097]:   print.tbl  pillar
2021-05-25T11:15:44.099489+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:44.099492+00:00 shinyapps[4164097]: Attaching package: ‘dplyr’
2021-05-25T11:15:44.099492+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:44.100245+00:00 shinyapps[4164097]: The following objects are masked from ‘package:stats’:
        2021-05-25T11:15:44.100245+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:44.100246+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:44.100246+00:00 shinyapps[4164097]:     filter, lag
2021-05-25T11:15:44.100607+00:00 shinyapps[4164097]: The following objects are masked from ‘package:base’:
        2021-05-25T11:15:44.100608+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:44.100609+00:00 shinyapps[4164097]:     intersect, setdiff, setequal, union
2021-05-25T11:15:44.100609+00:00 shinyapps[4164097]: 
        2021-05-25T11:15:44.285726+00:00 shinyapps[4164097]: Warning: Error in <Anonymous>: error reading from the connection
2021-05-25T11:15:44.293913+00:00 shinyapps[4164097]:   88: <Anonymous>

警告:匿名错误:从连接读取错误

这是我的 ui.R 代码:

library(shiny)
library(dplyr)
library(ggplot2)
library(readr)
df <- read_csv("country_vaccinations.csv.zip")
countries <- df %>% distinct(country)

fluidPage(
        titlePanel("Covid Vaccines by Country by Maria Freydlin"),
        h4("Instructions:"),
        h5("Please select a country from the dropdown list below to view the timeline of total vaccines administered within the last few months."),
        a(href="https://github.com/mariafreydlin/shinyapp/tree/master", 'Link to UI and Server code files'),
        titlePanel("Vaccine Timeline by Country"),   
        
        sidebarLayout(
                sidebarPanel(
                        selectInput( "country", "Country:", choices=countries),
                        hr()
                        
                ),
                mainPanel(
                        plotOutput("vaccinePlot")
                )
        )
)

这是我的服务器。R 代码:

library(shiny)
library(dplyr)
library(ggplot2)
library(readr)
df <- read_csv("country_vaccinations.csv.zip")

function(input, output){
        df_total <- reactive({
                df %>%
                        filter(country==input$country)%>%
                        group_by(date) %>%
                        summarise(total = sum(total_vaccinations, na.rm = T))
        })
        
        output$vaccinePlot <- renderPlot({
                ggplot(df_total(), aes(date, total)) + geom_line() +theme_bw()
        })
}

csv.zip 文件位于与 ui.R 和 server.ZE1E1D3D40573123D9AF201 相同的文件夹中。

有什么想法、建议吗?

正如 Eric 在评论中所建议的那样,我解压缩了 csv.zip 文件并改为读取.csv。 这解决了问题!

file = unzip("country_vaccinations.csv.zip")
df <- read_csv(file)

谢谢!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM