General Debugging Tips for Developing Shiny Apps

277 views
Skip to first unread message

Jeff Bruce

unread,
May 4, 2015, 4:00:42 PM5/4/15
to shiny-...@googlegroups.com
Hey Shiny useRs!

I have a number of questions which I think would be useful for other people testing their apps if there were answers to these particular questions.  Without further ado:
  1. It's difficult to predict how the styling will appear for a given app depending on the device/program with which you view it.  I've had occasions where firefox displays a checkboxGroupInput diagonally whereas this other browser (rekonq) displays a checkboxGroupInput vertically, and other odd behaviour, and it's just hard to predict what's going on here.  Another example is that shinyAppDir('/TestAppDir/') produces different styling than runApp(appDir='/TestAppDir/', launch.browser=TRUE) -- checkboxGroupInput boxes appear as X's for the former command whereas they appear as checks for the latter command. 
  2. Is there a way of changing the default browser that the app launches on if you run the app from RStudio?
  3. How would you recommend testing in various browsers simultaneously?  There are tools like browserstack, which I haven't used, but I imagine there are other best practices out there to make shiny apps appear nicely on as many browsers as possible.
  4. How does the control flow actually work when a Shiny app is launched (namely, the communication between server.R, ui.R, and global.R)?
  5. When you make a change to code in ui.R or server.R, and then immediately relaunch the app, sometimes those changes don't immediately take effect, and you have to wait an indeterminate amount of time for the changes to be displayed.  Is there a way of speeding up the process of: modify code -> test app -> wait -> test app -> wait -> ... -> test app -> result?
  6. Are there any supplementary resources beyond this one on general best practices for debugging Shiny apps?
  7. Is there more comprehensive Shiny documentation than that found at http://shiny.rstudio.com/articles?  In general the documentation is very good, I'm just wondering if there are any books or anything.

In general Shiny has been quite easy to pick up and it's pretty fun, I just want the community to get the most from it as possible :)

Joe Cheng

unread,
May 4, 2015, 6:13:38 PM5/4/15
to Jeff Bruce, shiny-...@googlegroups.com
1 & 3: For things like "x" versus check boxes, unless you want to become a professional web designer I suggest you try to get used to it--the cost of fixing and debugging such issues across all browsers is enormous and getting higher with each new platform that gets popular. I'm surprised to hear shinyAppDir(...) is different than runApp(...), unless those two are launching different browsers (perhaps the former is the RStudio preview window, while the latter is your system's default web browser?). And I'm also surprised to hear that Firefox displays checkboxGroupInput diagonally--can you send a screenshot of that?

2: You can call option(shiny.launch.browser = function(url) { ... }) where the function you're passing in launches the given URL in the web browser of your choice (probably using system()). Or just change your system's default web browser, and from the "Run App" toolbar button's menu, select "Run External".

4. global.R is run when the app is launched (i.e. no user has arrived yet), and it executes in the global environment. The shinyUI in ui.R is generally run once, and the results are saved; all this does is generate HTML which is served to any browser that arrives at the Shiny app's root URL. One of the things that HTML does is attempt to connect to the server using a websocket; when it does so, that's when the shinyServer function in server.R is executed.

5. I've never observed this. How much time are you needing to wait? What operating system are you using? What version of RStudio?

6. There are some slides on debugging here: https://speakerdeck.com/jcheng5/advanced-shiny (see slides 6-10)

7. We're strongly considering writing one. In the meantime there's one book by Packt Press that I know of: https://www.packtpub.com/web-development/web-application-development-r-using-shiny

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/8d36ffdb-5b6f-4113-99ed-e9107d7ba231%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Bruce

unread,
May 5, 2015, 2:25:29 PM5/5/15
to shiny-...@googlegroups.com, jeff...@gmail.com
Thanks Joe.  In response to some of these items:

1 & 3: You're right that shinyAppDir(...) launches in the RStudio preview window, which has different styling than browsers.

5: Upon further review, this only occurs for the rekonq browser that I'm using.  Firefox updates changes to ui.R and server.R immediately.

rekonq --version
Qt: 4.8.1
KDE Development Platform: 4.8.5 (4.8.5)
rekonq: 0.9.1

Not a big deal -- I'm just going to test with firefox as my default browser from now on.

Joe Cheng

unread,
May 5, 2015, 2:33:18 PM5/5/15
to Jeff Bruce, shiny-...@googlegroups.com
It's possible that rekonq is aggressively caching the HTML returned by Shiny--that would explain why you wouldn't see changes in ui.R, though not server.R.

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages