【问题标题】:Trouble Deploying r shiny app with dygraphs使用 dygraphs 部署 r 闪亮应用程序时遇到问题
【发布时间】:2018-09-26 03:57:57
【问题描述】:

我目前正在尝试将使用 dygraphs 包的 R Shiny 应用程序部署到 shinyapps.io。我的应用程序在本地运行良好,但是当我尝试部署它时说找不到网页 - “HTTP 500 内部服务器错误”。我的用户界面代码是:

shinyUI(fluidPage(

  titlePanel("MyApp"),

  fluidRow(
      column(12,
          p("Info Text")
          ,dygraphOutput("plot")
            ) 
          )
))

而服务器代码是:

shinyServer(function(input, output) {
  library(shiny)
  library(dygraphs)



    output$plot<- renderDygraph({
        data <- read.csv("data.csv", header=TRUE, sep =",",na.strings="-")
        dygraph(data, main = "Plot") %>%
          dyLegend(width = 170 , 
                   labelsSeparateLines = TRUE , 
                   show = "always") %>%
          dyOptions(stackedGraph = FALSE)

当我从 UI 代码中删除 dygraphOutput 函数时,应用程序部署成功。有没有人遇到过类似的 dygraphs 问题?

【问题讨论】:

  • 我认为您的csv 可能有问题,您可以dput(data) 并在此处发布输出
  • 结构(列表(年 = 2009:2015, A = c(0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.03), B = c(0.01, 0.01, 0.01, 0.01, 0.01) , 0.01, 0.01), C = c(0.06, 0.06, 0.08, 0.09, 0.11, 0.12, 0.14)), .Names = c("年份", "A", "B", "C"), class= "data.frame", row.names = c(NA, -7L))

标签: r shiny shiny-server dygraphs r-dygraphs


【解决方案1】:

对我来说一切正常,我认为问题在于您的 csv 文件。您可以看到我的应用程序在此代码下运行良好:

服务器

library(shiny)
library(dygraphs)

shinyServer(function(input, output,session) {

  data <- readRDS("data.rds")

  output$plot<- renderDygraph({
    req(data)
    dygraph(data, main = "Plot") %>% dyLegend(width = 170 , labelsSeparateLines = TRUE , show = "always") %>%dyOptions(stackedGraph = FALSE)
  })

})

用户界面

rm(list = ls())
library(shiny)
library(dygraphs)

ui <- fluidPage(
  titlePanel("MyApp"),
  fluidRow(
    column(12,p("Info Text"),dygraphOutput("plot")) 
  )
)

文件夹结构

最终输出

托管在 aws 上的应用

http://52.39.186.219:3838/Dygraphs/

【讨论】:

  • 当我在本地运行它时,这对我来说很好,但是一旦我部署它,我就会遇到问题。您是否能够毫无问题地部署应用程序?
  • 您最好将数据保存为.rds 文件并将该文件加载到Rshiny 的全局空间rdocumentation.org/packages/base/versions/3.4.3/topics/readRDS
  • 正如你所建议的,我保存为 .rds 文件并使用 readRDS 函数加载到文件中,但我仍然遇到同样的问题
  • 好的,非常感谢您的检查。问题可能与我帐户上的订阅有关吗?
  • 我不确定,如果你要部署到 shinyapps.io,请确保你没有设置任何 drictories,不幸的是我不知道
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-08
  • 2021-01-19
  • 2011-08-30
  • 1970-01-01
  • 2016-02-24
相关资源
最近更新 更多