Before we start…

\(\rightarrow\) LAST SESSIONS ? BONUS material!

Once Shiny is covered, I like to extend to the realm of R capabilities:

  • geocomputation: handling maps - you can integrate them in Shiny!
  • third party data: retrieving sets fro APIs (e.g.: twitter) + a bit of text mining (always useful)
  • machine learning: very powerful when used correctly

BUT: other options are possible:
- mentoring: help on your projects (needed?, needed!)
- a use case: a short tour on how I build small apps
- open to suggestions: go on & propose!

Key reminder: basic data science functions (tidyverse)

  • data wrangling: select() keeps only some columns, filter() keeps rows depending on some conditions, mutate() creates new columns (see Session 1).
  • pivot tables: perform an analysis on subgroups to simplify the data. group_by() defines the groups and summarize() the indicator (usually: mean(something) or n()).
diamonds %>% 
  group_by(cut) %>%
  summarise(avg_size = mean(carat)) 

Look at column names:

diamonds %>%
  group_by(cut, clarity) %>%
  summarise(nb_diamonds = n(), 
            avg_price = mean(price) %>% round(2)) 

Going further with shiny

Themes & styles

Going further with html & CSS

First, super simple intros to HTML & CSS:
https://www.internetingishard.com
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics
In notebooks & Shiny: http://dataviz-2021.netlify.app/slides/w9p2.html

The source: https://mastering-shiny.org/advanced-ui.html
The fresh package:
https://cran.r-project.org/web/packages/fresh/vignettes/fresh.html
https://github.com/dreamRs/fresh
One example of indirect (non visibly CSS) formatting:

font_avenir <- list(     # This is a formatting variable for plots' fonts
    family = "Avenir",   # This font has a modern look
    size = 9,
    color = 'grey')

p <-  movies %>% ggplot(aes(x = duration, y = imdb_score)) + geom_point() 
ggplotly(p) %>%
    layout(title = "Movies", font = font_avenir) # The font avenir is defined above

Going further with ggplot

General overview: https://exts.ggplot2.tidyverse.org/gallery/

Going pro

Good looking tables: references

See also:
https://rfortherestofus.com/2019/11/how-to-make-beautiful-tables-in-r/ https://appsilon.com/forget-about-excel-use-r-shiny-packages-instead/

Going even further with Shiny (this never stops)

DashboardPlus