3

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. :-|

Frank
  • 952
  • 1
  • 9
  • 23
  • 1
    Well, what exactly does the code look like? What exactly are you passing to `runApp` and `shinyApp`? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)that can be used to test and verify possible solutions. Make the most minimal example you can. – MrFlick Feb 20 '20 at 15:56
  • Thanks, I added code – Frank Feb 20 '20 at 16:14
  • 1
    Does it work for you when you don't specify the `host=`? Are you hosting this in your local machine? – MrFlick Feb 20 '20 at 16:17
  • I added an edit. It basically works when I use 127.0.0.1:, but as soon as I use my IP:or localhost:, it stops working – Frank Feb 20 '20 at 16:19
  • 1
    There's a separate parameter for `port=`. The `host=` should be just the IP address (not a host name). – MrFlick Feb 20 '20 at 16:22
  • The command I run in RStudio is : ```RunApp(app, host="", port=5050) ``` In browser, this displays incorrectly. If I instead run: ```runApp(app)``` It displays correctly at ```127.0.0.1:```, but incorrectly at ```localhost:``` Ultimately I want other machines in my local environment to see the app. – Frank Feb 20 '20 at 16:23
  • Do you have a firewall blocking the port? If you open the page up in Chrome and check the network tab in the developer tools, are the requests for the CSS pages and such being blocked? What version of `shiny` are you running? – MrFlick Feb 20 '20 at 16:31
  • I added an edit. In Chrome Devtools I am seeing : ```Failed to laod resource: the server responded with a status of 500 (Internal Server Error)``` for things such as : ```datatables-crosstalk.css:1``` – Frank Feb 20 '20 at 17:44
  • 1
    I'm not sure why that might be. To get further support you might try the RStuido support site: https://community.rstudio.com/ or fill out a github issue https://github.com/rstudio/shiny/issues – MrFlick Feb 20 '20 at 19:36
  • 1
    What is the name of the file containing the app. Are you using a www folder? I had [similar problems](https://github.com/daattali/shinycssloaders/issues/44) recently. – ismirsehregal Feb 20 '20 at 21:37
  • Thanks for all your help MrFlick, @ismirsehregal File name doesn't matter in this case, because the error occurred just by copying and pasting code into terminal. – Frank Feb 21 '20 at 15:14
  • Ok, thanks for the clarification. – ismirsehregal Feb 21 '20 at 16:08

0 Answers0