无法使用dygraph

时间:2018-04-16 12:00:39

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

我目前正在尝试部署使用dygraphs软件包到shinyapps.io的R闪亮应用程序。我的应用程序在本地工作正常,但当我尝试部署它时说找不到网页 - " HTTP 500内部服务器错误"。我的UI代码是:

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函数时,app会成功部署。有没有人遇到与dygraphs类似的问题?

1 个答案:

答案 0 :(得分:0)

对我来说一切正常,我认为问题出在您的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)
  })

})

UI

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

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

文件夹结构

enter image description here

最终输出

enter image description here

在aws上托管的应用

http://52.39.186.219:3838/Dygraphs/

相关问题