ShinyApp works but runApp doesnt R

777 Views Asked by At

Certain widgets are not working correctly when I use runApp, but when I use shinyApp, everything works fine. When I use runApp, I am specifying a host and port.

The widgets that are not working are pickerInput from shinyWidgets.

I think it's possibly a website not secure issue, not sure though.

This is what the site looks like with shinyApp:

enter image description here

This is what the site looks like with runApp:

enter image description here

EDIT:

here is example code:

library(shiny)
library(shinyWidgets)

app = shinyApp(
  ui = fluidPage(
    DT::dataTableOutput("responses", width = 300), tags$hr(),
    textInput("name", "Name", ""),
    checkboxInput("used_shiny", "I've built a Shiny app in R before", FALSE),
    sliderInput("r_num_years", "Number of years using R",
                0, 25, 2, ticks = FALSE),
    actionButton("submit", "Submit"),
    pickerInput(
        inputId = "lvl1", 
        label = "Level 1", 
        choices = c('one', 'two', 'three'), 
        options = list(
            `actions-box` = TRUE, 
            size = 10,
            `selected-text-format` = "count > 1"
        ), 
        multiple = TRUE
    )
  ),
  server = function(input, output, session) {


    output$responses <- DT::renderDataTable({
      data.frame(a = input$submit)
    })     
  }
)

if I just type this into RStudio, it works:

app

But, if I use runApp, the pickerInput widget does not display correctly in browser.

runApp(app, host="<some ip address>")

EDIT 2: if I use runApp(app), and open in browser, the app displays correctly. However, if I change the url in browser from 127.0.0.1:port to localhost:port, it stops displaying the widget correctly.

EDIT 3:

Errors from chrome dev tools

enter image description here

Edit4: It worked correctly after closing and re-opening the R session. :-|

0

There are 0 best solutions below