Using Shiny (RStudio) library on SAP Analytics Cloud

144 Views Asked by At

I've developed a perfectly functional app using Shiny package that I would like to run on SAC using its R functionalities; however, and despite Shiny being listed as one of the packages supported by SAC (https://blogs.sap.com/2020/03/18/r-packages-for-sap-analytics-cloud/) my app won't run.

I wish I could give you more details, but the script I run on R and the one I try to run on SAC are one and the same, as well as the mock up data; so it's beyond me why SAP won't let me do it. Am I missing something? Has anyone tried Shiny on SAC before without major issues?

Thanks in advance!

Edit: Here is my code, without needing any input data.


library(ggplot2)

ui <- fluidPage(
  titlePanel("Bass Diffusion Model Visualisation"),
  
  sidebarLayout(
    sidebarPanel(
      h2("Baseline model (blue)"),
      sliderInput(
        "innovation_base",
        "Innovation effect:",
        min = 0,
        max = 1,
        value = 0.03
      ),
      sliderInput(
        "imitation_base",
        "Imitation effect:",
        min = 0,
        max = 1,
        value = 0.38
      ),
      h2("Challenger model (red)"),
      sliderInput(
        "innovation",
        "Innovation effect:",
        min = 0,
        max = 1,
        value = 0.02
      ),
      sliderInput(
        "imitation",
        "Imitation effect:",
        min = 0,
        max = 1,
        value = 0.42
      )
    ),
    
    
   
    mainPanel(
      h2("Rate of adoption"),
      plotOutput("adoptionPlot"),
      h2("Cumulative adoption"),
      plotOutput("cumAdoptionPlot"))
  ))


server <- function(input, output) {
  output$adoptionPlot <- renderPlot({
    bass_base <-
      difcurve(
        n = 20,
        w = c(input$innovation_base, input$imitation_base, 100),
        type = "bass"
      )
    bass_challenger <-
      difcurve(
        n = 20,
        w = c(input$innovation, input$imitation, 100),
        type = "bass"
      )
    
    plot_adoption <- ggplot(as.data.frame(bass_base)) +
      aes(y = Adoption, x = 1:nrow(bass_base)) +
      geom_line(colour = "blue") +
      geom_line(data = as.data.frame(bass_challenger), colour = 'red') +
      labs(x = "years")
    
    plot_adoption
  })
  output$cumAdoptionPlot <- renderPlot({
    bass_base <-
      difcurve(
        n = 20,
        w = c(input$innovation_base, input$imitation_base, 100),
        type = "bass"
      )
    
    bass_challenger <-
      difcurve(
        n = 20,
        w = c(input$innovation, input$imitation, 100),
        type = "bass"
      )
    
    plot_cumAdoption <- ggplot(as.data.frame(bass_base)) +
      aes(y = `Cumulative Adoption`, x = 1:nrow(bass_base)) +
      geom_line(colour = "blue") +
      geom_line(data = as.data.frame(bass_challenger), colour = 'red') +
      labs(x = "years")
    
    plot_cumAdoption
  })
}

shinyApp(ui = ui, server = server)

The error I get is: 502 Bad Gateway: Registered endpoint failed to handle the request.

0

There are 0 best solutions below