3

我目前正在尝试将使用 dygraphs 包的 R 闪亮应用程序部署到 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问题?

4

1 回答 1

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)
  })

})

用户界面

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/

于 2018-04-16T12:29:10.430 回答