Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for...

19
Shiny applications without Shiny Emily Mitchell October 25, 2018

Transcript of Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for...

Page 1: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Shiny applications without Shiny

Emily MitchellOctober 25, 2018

Page 2: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

The views expressed in this presentation are those of the author and no official endorsement by the

Department of Health and Human Services, the Agency for Healthcare Research and Quality is intended or

should be inferred.

Disclaimer

Page 3: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

What is Shiny?

Page 4: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Motivation

Page 5: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Anatomy of a web pageHTML

Page 6: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Anatomy of a web pageHTML

JavaScript (JS)

Page 7: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Anatomy of a web page

Cascading Style Sheets (CSS)

Page 8: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Anatomy of a Shiny app

R – Shiny app

Page 9: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

HTML

JavaScript (JS)

R – Shiny app

Anatomy of a Shiny app

Page 10: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

1. Start with UI => HTML

2. Add JavaScript for reactivity

3. Add CSS (optional)

Tips for transitioning

Page 11: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

1. Start with UI => HTMLHTML

R – Shiny app

Page 12: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

2. Add JavaScript for reactivity

JavaScript (JQuery)R – Shiny app

Page 13: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

3. Add CSS (optional)

Page 14: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Shiny vs. JavaScript

Shiny JavaScript

Statistical programming

Data manipulation

Learning curve

Trouble-shooting

Customization

Speed

Page 15: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

You may want to transition if:

You don’t really need R

You use Shiny for display, not computation

You write your own R functions to create UI objects

You frequently use shinyBS and shinyJS packages, and find they don’t have all the features you want

You are writing and embedding custom HTML/JS/CSS into your Shiny app

Page 16: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

A happy medium?

Image credits: rstudio.com, deanattali.com/shinyjs/, ebailey78.github.io/shinyBS/

Style your apps with CSShttps://shiny.rstudio.com/articles/css.html

Customize your UI with HTMLhttps://shiny.rstudio.com/articles/html-tags.html

Build your entire UI with HTMLhttps://shiny.rstudio.com/articles/html-ui.html

How to create custom input bindingshttps://shiny.rstudio.com/articles/js-custom-input.html

Use R shiny as a server for JavaScript

Page 17: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Transition example

https://github.com/e-mitchell/Shiny_JS_transition

R – Shiny app HTML / JS

Page 18: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

summary tables

https://github.com/HHS-AHRQ/MEPS-summary-tables

Page 19: Shiny applications without Shiny · 24/10/2018  · You don’t really need R You use Shiny for display, not computation You write your own R functions to create UI objects You frequently

Resources

[email protected]

Shiny tutorials https://shiny.rstudio.com/articles

Learning HTML / CSS / JS coursera.org/specializations/web-designw3schools.com

Bootstrap getbootstrap.com

US Web Design Standards (USWDS)

standards.usa.gov

Web Accessibility (508 compliance)

webaim.org