class: center, middle, inverse, title-slide # RStudio::conf 2020 ## Reflections ### .left[
_Anna Krystalli_] ### .left[
2020-03-04, Sheffield R Users Group
] --- # 👋 Hello ### me: **Dr Anna Krystalli** - **Research Software Engineer**, _University of Sheffield_ +
**@annakrystalli** +
**@annakrystalli** +
**a.krystalli[at]sheffield.ac.uk** - **Editor [rOpenSci](http://onboarding.ropensci.org/)** - **Co-organiser:** [Sheffield R Users group](https://www.meetup.com/SheffieldR-Sheffield-R-Users-Group/) <br> --- layout: true .footnote[
@annakrystalli] --- ## Rstudio::conf 2020 #####
San Francisco, USA
25 - 28 Jan > ### 2 days of [Workshops](https://rviews.rstudio.com/2020/01/27/rstudio-conf-2020-workshopsr/) > > - All materials [available](https://github.com/rstudio-conf-2020) > > ### 2 days of talks > > - All [recorded](https://resources.rstudio.com/rstudio-conf-2020) --- class: inverse, middle .center[ ## Data visualisation ] --- ## [Data, visualization, and designing AI](https://resources.rstudio.com/rstudio-conf-2020/data-visualization-and-designing-ai-fernanda-viegas-and-martin-wattenberg) #### _Fernanda Viegas & Martin Wattenberg_ <img src="assets/rstudioconf-pair.png" width="60%" /> --- ## [Facets - KNOW YOUR DATA](https://pair-code.github.io/facets/) .pull-left[ ### Better data leads to better models. ] .pull-right[ **Understanding your data is critical to building a powerful machine learning system.** - **Facets Overview:** Get a sense of the shape of each feature of your dataset - **Facets Dive.** explore individual observations ] --- ## Facets Overview Summary exploration of data .pull-left[ <img src="assets/rstudioconf-facets-overview1.png" width="1955" /> ] .pull-right[ <img src="assets/rstudioconf-facets-overview2.png" width="1661" /> ] --- ## Facets Dive Exploration of individual datasets .pull-left[ <img src="assets/rstudioconf-facets-matrix.png" width="5376" /> ] .pull-right[ <img src="assets/rstudioconf-facets-hist.png" width="5376" /> ] --- ## Facets Dive - Quick Draw [](https://pair-code.github.io/facets/quickdraw.html) --- ## [People + AI Research (PAIR)](https://research.google/teams/brain/pair/) PAIR is devoted to **advancing the research and design of people-centric AI systems**. We're interested in the full spectrum of human interaction with machine intelligence, from supporting engineers to understanding everyday experiences with AI. #### [People + AI Guidebook](https://pair.withgoogle.com/) <img src="assets/rstudioconf-pair-guidebook.png" width="837" /> --- ## [Auto-magic Package Development](https://resources.rstudio.com/rstudio-conf-2020/auto-magic-package-development-alicia-schep) #### _Alicia Schep_ **`vlbuildr`**: R functional interface for [Vega-Lite](https://vega.github.io/vega-lite/) graphics <img src="assets/rstudioconf-vlbuildr.png" width="70%" /> --- ### Vegalite <img src="assets/rstudioconf-vlbuildr-json.png" width="4592" /> --- ### Vegalite <img src="assets/rstudioconf-vlbuildr-api.png" width="4868" /> --- ## `vlbuildr` in action ```r vl_chart() %>% vl_add_data(url = "https://vega.github.io/vega-editor/app/data/cars.json") %>% vl_mark_point() %>% vl_encode_x(field = "Horsepower", type = "quantitative") %>% vl_encode_y(field = "Miles_per_Gallon", type = "quantitative") %>% vl_encode_color(field = list("repeat" = "column"), type = "nominal") %>% vl_repeat_col("Origin", "Cylinders") %>% vl_resolve_scale_color("independent") ``` ---
--- class: inverse, middle .center[ # the stuff of dreams ] --- ## [Shiny styling](https://resources.rstudio.com/rstudio-conf-2020/styling-shiny-apps-with-sass-and-bootstrap-4-joe-cheng) w `bootstraplib` #### _Joe Cheng_ <img src="assets/rstudioconf-shiny-boot-custom.png" width="1132" /> --- ## [Shiny styling](https://resources.rstudio.com/rstudio-conf-2020/styling-shiny-apps-with-sass-and-bootstrap-4-joe-cheng) w `bootstraplib` .pull-left[ <img src="assets/rstudioconf-shiny-boot-sass-replace.png" width="1204" /> ] .pull-right[ <img src="assets/rstudioconf-shiny-boot-sass.png" width="1633" /> ] --- <img src="assets/rstudioconf-shiny-boot.png" width="1395" /> --- ## `bootstraplib` addin <img src="assets/rstudioconf-shiny-boot-addin.png" width="55%" /> --- ## [Reproducible shinyapps w `shinymeta`](https://resources.rstudio.com/rstudio-conf-2020/reproducible-shiny-apps-with-shinymeta-dr-carson-sievert) #### _Carson Sievert_ <img src="assets/rstudioconf-shinymeta-prob.png" width="1452" height="20%" /> --- ### Example `shinymeta` .pull-left[ <img src="assets/rstudioconf-shinymeta-example1.png" width="1549" /> ] .pull-right[ <img src="assets/rstudioconf-shinymeta-example2.png" width="1656" /> ] --- ### `shinymeta` usage <img src="assets/rstudioconf-shinymeta-code.png" width="1731" /> --- ### `shinymeta` outputs .pull-left[ <img src="assets/rstudioconf-shinymeta-out1.png" width="1664" /> ] .pull-right[ <img src="assets/rstudioconf-shinymeta-out2.png" width="1643" /> ] --- ## [Interactivity and Programming in the Tidyverse](https://resources.rstudio.com/rstudio-conf-2020/interactivity-and-programming-in-the-tidyverse-lionel-henry) #### _Lionel Henry_ advances in the tidy eval framework that make it easier to program around tidyverse pipelines without having to learn a lot of theory. --- ## Data-masking > ### Idea of blending data with the workspace ```r lm(Sepal.Length ~ Sepal.Width, data = iris) ``` ``` ## ## Call: ## lm(formula = Sepal.Length ~ Sepal.Width, data = iris) ## ## Coefficients: ## (Intercept) Sepal.Width ## 6.5262 -0.2234 ``` --- ## Data-masking > #### Creates ambiguity between **data-variables** and **environment-variables** - unexpected masking by data-variables - data-variables that can't pass through functions --- ### Masking by data-variables .pull-left[ ```r n <- 100 data.frame(x = 1) %>% mutate(y = x / n) %>% pull(y) ``` ``` ## [1] 0.01 ``` ] .pull-right[ ```r data.frame(x = 1, n = 2) %>% mutate(y = x / n) %>% pull(y) ``` ``` ## [1] 0.5 ``` ] --- ### Masking by data-variables #### Solution: Be explicit! ```r data.frame(x = 1, n = 2) %>% mutate(y = .data$x / .env$n) ``` ``` ## x n y ## 1 1 2 0.01 ``` Use **`.env`** pronoun to refer to objects in environment and `.data` for data columns --- ### Passing data-variables through funtions ```r mean_by <- function(data, by, var){ data %>% group_by(by) %>% summarise(avg = mean(var)) } ``` ```r iris %>% mean_by(Species, Petal.Length) ``` ``` ## Error: Column `by` is unknown ``` --- ### Passing data-variables through funtions Tunnel data variable through env-variable with **`{{ }}`** ```r mean_by <- function(data, by, var){ data %>% * group_by({{ by }}) %>% * summarise(avg = mean({{ var }})) } ``` ```r iris %>% mean_by(Species, Petal.Length) ``` ``` ## # A tibble: 3 x 2 ## Species avg ## <fct> <dbl> ## 1 setosa 1.46 ## 2 versicolor 4.26 ## 3 virginica 5.55 ``` --- ### Programmable result name Use glue string! ```r mean_by <- function(data, by, var){ data %>% group_by({{ by }}) %>% * summarise("{{ var }}" := mean({{ var }})) } ``` ```r iris %>% mean_by(Species, Petal.Length) ``` ``` ## # A tibble: 3 x 2 *## Species Petal.Length ## <fct> <dbl> ## 1 setosa 1.46 ## 2 versicolor 4.26 ## 3 virginica 5.55 ``` --- ## Writting functions with data masking propagates it <br> > ### Users will need to be aware! --- ### Wrap tidy pipelines without data-masking? ```r mean_by <- function(data, by, var){ data %>% * group_by(.data[[by]]) %>% * summarise("{var}" := mean(.data[[var]])) } ``` ```r iris %>% mean_by("Species", "Petal.Length") ``` ``` ## # A tibble: 3 x 2 ## Species Petal.Length ## <fct> <dbl> ## 1 setosa 1.46 ## 2 versicolor 4.26 ## 3 virginica 5.55 ``` --- ## [Rstudio 1.3 Sneak Preview](https://resources.rstudio.com/rstudio-conf-2020/rstudio-1-3-sneak-preview-jonathan-mcpherson) #### _Jonathan McPherson_ <img src="assets/rstudioconf-1.3gr.png" width="65%" /> --- ## Rstudio 1.3 Sneak Preview .pull-left[ <img src="assets/rstudioconf-1.3schk.png" width="5376" /> ] .pull-right[ <img src="assets/rstudioconf-1.3schk2.png" width="5376" /> ] --- class: inverse, middle .center[ # masters of entertainment ] --- ## [Learning R with humorous side projects](https://resources.rstudio.com/rstudio-conf-2020/learning-r-with-humorous-side-projects-ryan-timpe) #### _Ryan Timpe_ <p><a href="https://resources.rstudio.com/rstudio-conf-2020/learning-r-with-humorous-side-projects-ryan-timpe?wvideo=13385r30ep"><img src="https://embedwistia-a.akamaihd.net/deliveries/5ebafbb4ab5f032c58d89c9e3d48bbca.jpg?image_play_button_size=2x&image_crop_resized=960x540&image_play_button=1&image_play_button_color=4287c7e0" width="400" height="225" style="width: 400px; height: 225px;"></a></p> --- ##### Q: Which season should I watch while playing the Golden Girls Drinking Game? <img src="assets/rstudioconf-humour-ggirls.png" width="70%" /> --- ### Animated paths of Jurassic Park characters <img src="assets/rstudioconf-humour-jpark2.png" width="70%" /> --- ### Learn new tools! <img src="assets/rstudioconf-humour-tools.png" width="70%" /> --- ### [One R Markdown Document, Fourteen Demos](https://resources.rstudio.com/rstudio-conf-2020/one-r-markdown-document-fourteen-demosyihui-xie?wvideo=aj3deolth1) #### _Yihui Xie_ <p><a href="https://resources.rstudio.com/rstudio-conf-2020/one-r-markdown-document-fourteen-demosyihui-xie?wvideo=aj3deolth1"><img src="https://embedwistia-a.akamaihd.net/deliveries/995470d4b099ae9b3421014c31c22716.jpg?image_play_button_size=2x&image_crop_resized=960x539&image_play_button=1&image_play_button_color=4287c7e0" width="400" height="225" style="width: 600px; height: 375px;"></a></p> --- class: inverse, middle .center[ # feel good moments ] --- ## R-ladies! <blockquote class="twitter-tweet"><p lang="en" dir="ltr">Hello 👋 from <a href="https://twitter.com/hashtag/RLadies?src=hash&ref_src=twsrc%5Etfw">#RLadies</a> at <a href="https://twitter.com/hashtag/rstudioconf?src=hash&ref_src=twsrc%5Etfw">#rstudioconf</a>!!💜 <a href="https://t.co/lTUK2Ap9bc">pic.twitter.com/lTUK2Ap9bc</a></p>— R-Ladies Global (@RLadiesGlobal) <a href="https://twitter.com/RLadiesGlobal/status/1223082687759441920?ref_src=twsrc%5Etfw">January 31, 2020</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> --- ## RStudio, PBC .pull-left[ #### _J.J. Allaire_ <iframe allowtransparency="true" title="Wistia video player" allowFullscreen frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" src="https://fast.wistia.net/embed/iframe/i7lqqlo6ng" width="400" height="225"></iframe> ] .pull-right[ **Primary purpose:** [Create free and open-source software for data science, scientific research, and technical communication.](https://blog.rstudio.com/2020/01/29/rstudio-pbc/) <img src="assets/cert_bcorp.png" width="903" /> ] --- class: inverse, middle ## Thanks for 👀 ### slides: **bit.ly/rstudioconf20**