首页 > 解决方案 > Shiny App 在本地工作,但不在 ShinyApps.io 服务器上

问题描述

我部署我的应用程序并打开,但返回一条错误消息并说要检查我的日志。

我相信这与我的 postgres 数据库连接或我用来绘制该信息的逻辑有关。

server <- function(input, output){


# Get Athlete Data From Database
DataTable <- reactive({
  query <- DBI::sqlInterpolate(con, queryTable, athleteName = 
  input$athleteSearch)
  DataTable <- RPostgreSQL::dbGetQuery(con, query)
  return(DataTable)
})


output$lineGraph <- renderPlot({
  require(input$athleteSearch)

# Create Line Graph
  LineGraph <-
  DataTable() %>%
  mutate(date_tested = as.Date(date_tested)) %>%
  select(date_tested, strength, fluidity, power, momentum) %>%
  ggplot(aes(x = date_tested, y= strength)) + geom_line(aes(group = 1, 
  color = "strength"), size = 1.5) +
  geom_line(aes(x = date_tested, y = fluidity, group = 1, color = 
  "fluidity"),  size = 1.5) +
  geom_line(aes(x = date_tested, y = power, group = 1, color = 'power'),  
  size = 1.5) +
  geom_line(aes(x = date_tested, y = momentum, group = 1, color = 
  'momentum'), size = 1.5) +
  xlab("Date Tested") + ylab("Score") + 
  scale_color_manual(values = c('red', 'orange', 'dark red', 'black')) + 
  theme_bw()

  return(LineGraph)
})

}

这是不起作用的部分

它说“发生错误。检查您的日志。”

日志返回此消息:

if (!loaded) { : 2019-08-22T13:41:22.289154+00:00 shinyapps[1104020] 中的警告:条件的长度 > 1,仅使用第一个元素 2019-08-22T13:41:22.289735 +00:00 shinyapps[1104020]: c("加载所需包:$"、"加载所需包:输入"、"加载所需包:报告") 2019-08-22T13:41:22.290211+00:00 shinyapps [ 1104020]:失败并出现错误:''package' 的长度必须为 1' 2019-08-22T13:41:22.292493+00:00 shinyapps [1104020]:条件的长度 > 1,并且仅使用第一个元素 2019 -08-22T13:41:22.292492+00:00 shinyapps[1104020]: if (!loaded) { : 2019-08-22T13:41:22.292920+00:00 shinyapps[1104020]: c("Loading required package : $", "加载需要的包:输入", "加载需要的包:报告") 2019-08-22T13:41:22.293325+00:00 shinyapps[1104020]: 失败并出现错误:''package' 的长度必须为 1'</p>

标签: rshiny

解决方案


我猜你library()的代码中有你的调用,因为它们在上面丢失了。

无论如何,我相信您缺少有关要连接到的数据库的主机/端口/用户/密码的信息。请参阅https://github.com/r-dbi/RPostgres


推荐阅读