3

I'm currently attempting to deploy my R shiny app which uses the dygraphs package to shinyapps.io. My app works fine locally but when I try to deploy it says the webpage cannot be found - "HTTP 500 Internal Server Error". My UI code is:

shinyUI(fluidPage(

  titlePanel("MyApp"),

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

and server code is:

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)

When I remove the dygraphOutput function from the UI code the app deploys successfully. Has anyone experienced similar problems with dygraphs?

ASmith
  • 33
  • 4
  • i think there might be a problem with your `csv`, can you do `dput(data)` and post the output here – Pork Chop Apr 16 '18 at 12:21
  • structure(list(Year = 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("Year", "A", "B", "C"), class = "data.frame", row.names = c(NA, -7L)) – ASmith Apr 16 '18 at 12:26

1 Answers1

0

Everything works fine for me, i think the issue is with your csv file. You can see that my app works fine with this code:

Server

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

Folder structure

enter image description here

Final Output

enter image description here

The app hosted on aws

http://52.39.186.219:3838/Dygraphs/

Pork Chop
  • 28,528
  • 5
  • 63
  • 77
  • This works fine for me when I run it locally also, but once I deploy it that's when I encounter the issue. Are you able to deploy the app with no issues? – ASmith Apr 16 '18 at 12:32
  • you better save your data as `.rds` file and load that file into Rshiny in a global space https://www.rdocumentation.org/packages/base/versions/3.4.3/topics/readRDS – Pork Chop Apr 16 '18 at 12:33
  • As you suggested I saved as .rds file and loaded in the file using the readRDS function but I'm still experiencing the same issue – ASmith Apr 16 '18 at 12:57
  • Ok, thanks a lot for checking that out. Could the issue be something to do with the subscription on my account? – ASmith Apr 16 '18 at 13:14
  • I'm not sure, if you're deploying to `shinyapps.io` make sure you dont set any drictories, other than that I don't know unfortunately – Pork Chop Apr 16 '18 at 13:16