R Shiny Server 500 error deploying app with plotly

Hello,

I have a shiny app which works correctly with ggplot. If, however I add plotly and rewrite accordingly, it works only when using “Run App” command in RStudio Server, but not when deployed on the shiny-server:3838

The error I get is: The application exited during initialisation. and in the browser console I see the server responded with a status of 500 (Internal Server Error).

Has anyone encountered this issue before?

I also get the same exact issue if I use the code sample provided by plotly-r website here

library(shiny)
library(plotly)

ui <- fluidPage(
  selectizeInput(
    inputId = "cities", 
    label = "Select a city", 
    choices = unique(txhousing$city), 
    selected = "Abilene",
    multiple = TRUE
  ),
  plotlyOutput(outputId = "p")
)

server <- function(input, output, ...) {
  output$p <- renderPlotly({
    plot_ly(txhousing, x = ~date, y = ~median) %>%
      filter(city %in% input$cities) %>%
      group_by(city) %>%
      add_lines()
  })
}

shinyApp(ui, server)

Thanks for your help

This was solved by installing the plotly library from the terminal with this command:

sudo su - -c "R -e \"install.packages('plotly', repos='http://cran.rstudio.com/')\"