How to I put a link on an R Shiny histogram bin so that I can open a second R Shiny application?

56 views
Skip to first unread message

Warren Weis

unread,
Nov 7, 2016, 11:11:59 AM11/7/16
to Shiny - Web Framework for R

Master/Detail:


I really am a rank beginner with R and Shiny, but I've been asked to write a proof of concept report (graph) to see if we should switch to this platform. So, I've bought a book and started looking at examples I've found on the web, but I hope someone can point me in the right direction for documentation on a good approach to the problem I've been set.


We would like to have a master/detail report. 


In the master report, the user is presented with a histogram. Click on a histogram bin and a window opens with the detail report.

Specifically, we are reporting deaths by county (US) by day in the histogram master. When the user clicks on one of the counties (one of the histogram bins), they should be presented with a list of death records for that county for that day.


We'd like to know how hard it would be to do a report of this type in R Shiny. I am hoping that someone can point me to a specific example of R that does something similar or to the documentation I should look at for what I am trying to do.

I'd imagine something like a link on each county bin, but I could not see a way to do that using the hist() function.

Joe Cheng

unread,
Nov 7, 2016, 12:24:59 PM11/7/16
to Warren Weis, Shiny - Web Framework for R
Here's a stripped down example of a master/detail view:

You'll first need to install shiny, ggplot2 and DT:
install.packages(c("shiny", "ggplot2", "DT"))

Then you can run it with:

I wouldn't necessarily say this is particularly advanced Shiny code, but you will need to know a bit about reactive programming to understand it.
https://www.rstudio.com/resources/webinars/shiny-developer-conference/ (Effective Reactive Programming parts 1 and 2)

Handling the actual plot clicks is the interactive plots feature; you'll find the first in a series of three articles here:

The trickiest bit will be having it open "in a new window". Shiny is currently designed for "single page applications" (SPA) so it's not natural to have two separate pages as part of the same app. However there's several options to deal with that.

  1. Don't actually open a new window, just have it load in the same page, as I have in this example.
  2. Use tabsetPanel or navbarPage to separate the two views but still have them on the same page
  3. Use modal dialogs for the detail view
  4. There are techniques you can use to get Shiny to render multiple pages, after a fashion. We're currently working on an example app and article for one of these techniques. For someone just starting out with Shiny, though, I'd recommend one of the other options.


--
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/051e5a18-ffb5-4d93-b4b1-3a4792bd6800%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages