76

At the risk of getting hit with a mods "too broad a question" hammer, I want to ask given the plethora of interactive R Shiny tools and packages emerging, when do you use which one?

  1. Shiny - to me only downside your project needs to run from shiny server but seems the best choice.

  2. shinydashboard - Shiny but has nice Value boxes for callouts.

  3. flexdashboard - write it up in Rmd. What does that gain you that straight Shiny does not? Perhaps, useful to email to a client provided you are happy to pass over data? I have been playing around with flexdashboard but its inability to work with datatable (library(DT)) makes me feel like it needs a few more iterations.

Looking at other answers, I am not alone in asking this question.

The creators are providing lots of galleries out there to showcase their packages/approach, but how do you know which path to go on?

What are the clear advantages of using one over the other?

Community
  • 1
  • 1
micstr
  • 5,080
  • 8
  • 48
  • 76
  • 4
    What is your input, and expected output? Just kidding man. This is a useful question and will hopefully generate some good answers. – cory Jun 23 '16 at 13:01
  • 12
    Well @cory I have one downvote already so the monkey hammer is working. I wish SO would worry more thinning out the duplicate student homework questions, than topics like this where gurus can share their experiences... – micstr Jun 23 '16 at 13:04
  • 1
    I believe that you need Shiny Server for all options here, if you want to deploy your app to a server (not just running inside RStudio). – Xiongbing Jin Jun 23 '16 at 14:55
  • 1
    You should be able to use useful elements from one option in another as well, as all of them are based on R/Shiny/RMarkdown. Which one to use depends on what you want to achieve: A dashboard to show more static content? A report that needs periodic update? An interactive application where people can change lots of parameters? – Xiongbing Jin Jun 23 '16 at 15:01
  • Thanks @warmoverflow for your thoughts. Ideally I would like an interactive dashboard with a nice print a report button once users get the insight they want. – micstr Jun 28 '16 at 10:19
  • I have the same question. Where will flexdashboard be in 2 years? Should I be relying on it for a mid-sized to big project? It's not clear to me if pure HTML can be embedded into flexDB. – Dan Sep 12 '16 at 11:08
  • @Dan Just been at a Adv Workshop with RStudio team. New Shiny developments are htmltemplates (so you can embed shiny bits into your pages - I think you will like this), Modules (to make code more portable between projects), modals (so no more ShinyBS needed) and Bookmarkable state(save input choices to send a page not on default state). Lots of stuff on http://shiny.rstudio.com/articles/. Rstudio mgt said that `flexdashboard` will keep being supported. – micstr Sep 17 '16 at 11:31
  • @micstr Awe! Many thanks. Glad to hear. Do you have more info on how to save input choices for the next login? – Dan Sep 25 '16 at 23:34
  • How much back and forth do you need between R and the html/js? `crosstalk` is alpha at this point but certainly functional enough to use. It provides a channel for shiny and non-shiny communication between `htmlwidgets` and other html/js. If you expect to use R to build/render and then don't need R after the initial build then I would recommend a non-shiny approach. RStudio has done a fantastic job bringing these JS/HTML technologies to R, but I often wonder if I should rely more on popular, well-supported HTML/JS/CSS frameworks for my layout and styling. – timelyportfolio Oct 05 '16 at 13:39
  • Turned out I shouldn't use flexdashboard as it seems not flexible as Shiny, for example [I can't update input box values in reactive way](https://stackoverflow.com/questions/45839542/how-to-use-updateselectinput-in-flexdashboard?noredirect=1#comment78636333_45839542). – Deqing Aug 27 '17 at 13:32
  • 'Firstly, the strength of Flexdashboard (example) is its basis on R Markdown, yielding an unmatched user interface (front-end). Secondly, the strength of Shiny (example) is the input reactivity (back-end) it offers, allowing users to download sections of data they select, in various formats. Last, Flexdashboard-Shiny (example) combines the best of both worlds. Flexdashboard types are rendered as an HTML document—simple websites—, and can therefore be easily published on personal sites or RPubs.' Read more at: https://github.com/pablobernabeu/Data-is-present#trade-offs-among-dashboards – Pablo Bernabeu Feb 18 '20 at 02:32

4 Answers4

27

There's one nuance that needs to be made. Interactivity does not necessarily require a server behind it running code. Interactivity can be provided using embedded JavaScript, which would execute at the client-side (like plotly, highcharts, leaflet etc). So if we don't use the word "interactivity", but describe the interactivity explicitly, then your options become:

  • Shiny: Needs a server behind it to execute R code on user input. Can implement any layout. Can run interactive code either by processing serverside (in R) or clientside (in embedded JavaScript).
  • shinydashboard:Needs a server behind it to execute R code on user input. Can implement a dashboard layout. Contains some specific widgets designed to work in a dashboard layout. Can run interactive code either by processing serverside (in R) or clientside (in embedded JavaScript).
  • flexdashboard: Just a document that looks like a dashboard. Also contains some specific widgets designed to work in a dashboard layout. Can only run interactive code clientside (in embedded JavaScript).

So basically, if whatever interactivity is required can be offered by an existing package (that uses htmlwidgets), then you can just use flexdashboard and you don't need to deploy it to any Shiny server. Otherwise, you do need to deploy to a Shiny server and you should use either Shiny, or shinydashboard.

Amit Kohli
  • 2,860
  • 2
  • 24
  • 44
14

I like to put shiny modules inside a flexdashboard. As long as you put runtime: shiny in your YAML header section, using shiny modules should be relatively straightforward. By relative, I mean, take a day and read over all the examples from RStudio, then try to do the same with your code. Once you're over the learning curve, modules in flexdashboards make future development much more streamlined, mentally easy, and in my experience, afford me the opportunity to really focus on the underlying data-based questions I've been asked to address. I think flexdashboards + shiny modules is the best of both worlds: flexdash to break up some of the layout items, easily add or remove a section of code, isolate various aspects of your application code in a more visually distinct layout (the shading of 'chunks' in an RMD file, etc.), while still allowing you to get into more complex, quintessentially shiny things like setting up observers, proxies, or custom layouts.

nate
  • 1,172
  • 1
  • 11
  • 26
11

I do not agree that you need to have Shiny Server to run a shiny app. I simply host my shiny app on our server at port 5050 (behind firewall) and any client can access the app via ip:port. I am only running 1 session of RStudio to accomplish this.

If I were to turn on port forwarding through our router, this app would also be accessible over the internet- but for security reasons I do not allow this.

I like the flexibility that Shiny offers to customize the web page.

ShinyDashboard is great in that it provides a commercial appearance without having to write all of the css and html yourself.

Flexdashboard is also nice in that you may be hosting it on a service that can handle markdown rather than inserting the app via an iFrame or something else.

Alex Dometrius
  • 812
  • 7
  • 20
8
  1. shinydashboard has better UI elements than default shiny, but it's just like a modern theme. I don't think it should be listed as competitor to other 2.
  2. flexdashboard is just enhanced RMarkdown, using simple convention for UI arrangement, htmlwidgets etc. You can use Shiny in it but it's limited.
  3. To use Shiny you will need to write more code for UI and behavior, learn more things related to html, css, especially reactive which need some time to grasp. In the end you get all the power and controls.
dracodoc
  • 2,603
  • 1
  • 23
  • 33