class: title-slide background-image: url(data:image/png;base64,#images/cover-1-ws.png) background-size: cover # How to be a pollinatoR <br> <br> #### rstudio::conf(2022) Kiegan Rice Weihuang Wong --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### Bees -- .strong[R users have a lot in common with bees.] .pull-left[ <img src="data:image/png;base64,#images/bee-honeycomb.jpg" title="A bee crawling on honeycomb." alt="A bee crawling on honeycomb." width="75%" /> ] -- .pull-right[ <img src="data:image/png;base64,#images/rstudio-hexes.jpg" title="R package hex stickers" alt="R package hex stickers" width="95%" /> ] .footnote[ [1] https://commons.wikimedia.org/wiki/File:Western_honey_bee_on_a_honeycomb.jpg [2] https://www.rstudio.com/blog/r-and-rstudio-the-interoperability-environment-for-data-analytics/ ] --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### Bees .strong[Bees are pollinators.] .pull-left[ <blockquote> The pollinator population of an area is a great indicator of the overall health of an ecosystem.<sup>3</sup> </blockquote> ] .pull-right[ <img src="data:image/png;base64,#images/bee-flower.jpg" title="A bee with a flower." alt="A bee with a flower." width="60%" style="display: block; margin: auto;" /> ] .footnote[ [3] https://www.nrcs.usda.gov/wps/portal/nrcs/detail/pa/plantsanimals/?cid=nrcs142p2_018171 [4] Image: https://www.flickr.com/photos/supersum/5853429721 ] --- .slide-header[HOW TO BE A POLLINATO.strong[R]] <br></br> <br></br> <!-- <center> --> <h2> Like bees, R users can enrich their own data ecosystem, with effort and empathy. </h2> <!-- </center> --> --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### Data ecosystem <!-- A few words about who we are, what is this thing we call a data ecosystem, and why we care about it. Kiegan and I work at NORC, a nonpartisan social research organization. At NORC, our coworkers, partners, and clients use a variety of software: R, of course, but also SAS, Excel, and Stata. We create lots of documentation that accompany our data products, also in a variety of formats, like Word and PDF. We work with folks who are expert coders, beginner coders, non-coders. That's what we mean by an ecosystem: an environment where there are people with a variety of skills, using a variety of software, creating a range of products. As R users and developers, we play a lot of roles on projects. And just like bees, to complete tasks we need to leave the hive and interact with others. The great thing about R is that other R developers have done a lot of the hard work to help with this interaction, and we'll talk about some of these tools in a second. --> <img src="data:image/png;base64,#images/pollinator-drawing-01.png" width="80%" style="display: block; margin: auto;" /> --- count: false .slide-header[HOW TO BE A POLLINATO.strong[R]] ### Data ecosystem <img src="data:image/png;base64,#images/pollinator-drawing-02.png" width="80%" style="display: block; margin: auto;" /> --- count: false .slide-header[HOW TO BE A POLLINATO.strong[R]] ### Data ecosystem <img src="data:image/png;base64,#images/pollinator-drawing.png" width="80%" style="display: block; margin: auto;" /> <!-- --- --> <!-- .slide-header[HOW TO BE A POLLINATO.strong[R]] --> <!-- ### Your presenters --> <!-- TODO: Our background, why we care --> <!-- We work on teams with a variety of goals and a variety of skills --> <!-- - Teams are a mix of skills --> <!-- - Some R or python users --> <!-- - A lot of SAS and Stata users --> <!-- - Many non-coders --> <!-- - Creating a variety of products --> <!-- - Written reports, codebooks and data, policy briefs, interactive data viz applications, static data viz, etc. --> <!-- We play a lot of roles on projects... and just like bees, to complete tasks we need to leave the hive and interact with others. --> --- .slide-header[HOW TO BE A POLLINATO.strong[R]] <!-- By enriching the data ecosystem, we mean helping others be better at doing their jobs, regardless of the tools they use or their level of coding expertise. This is what pollinators do: they help everyone else thrive. Why do we believe so strongly in the role of R users as pollinators? --> </br> ## strengthen the ecosystem we succeed or fail together ## make honey we do better work when others do better work ## build the hive build institutional support for R --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### Technical empathy <!-- Being part of an ecosystem means that you quickly learn that other people see things differently than you do. Biologists have a word for it: Umwelt. An Umwelt refers to the perceptual world of an animal. Every species senses in its own way. Bats and whales hear the world in a way that humans do not. Two species sharing the same physical environment may have two different experiences of this environment. Here’s where empathy comes in. Among the species, humans are unique in that they have a capacity to appreciate other Umwelten. In our context, this is what we mean by empathy: being able to perceive data and perceive code in the way that others do. --> .strong[Umwelt] <blockquote> an Umwelt is... an animal['s]... perceptual world.... Our Umwelt is all we know, and so we easily mistake it for all there is to know.... Humans, however, possess the unique capacity to appreciate the Umwelten of other species....<sup>4</sup> </blockquote> <img src="data:image/png;base64,#images/echo.jpg" title="Bat echolocation" alt="Bat echolocation" width="33%" style="display: block; margin: auto;" /> .footnote[ [5] Ed Yong. "Our Blinding, Blaring World." <i>The Atlantic</i> July/August 2022, pp. 65. [6] "Echolocation." http://www.nhc.ed.ac.uk/index.php?page=24.134.166.169.182 ] --- class: primary, inverse background-image: url(data:image/png;base64,#images/section-1-ws.png) background-size: cover # 1. Do no harm --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 1. Do no harm .pull-left[ <img src="data:image/png;base64,#images/gss-maeduc-missing2.png" title="GSS MAEDUC variable description and summary table" alt="GSS MAEDUC variable description and summary table" width="85%" /> .footnote[[7] <i>2021 GSS Documentation and Public Use File Codebook (Release 2).</i> https://gss.norc.org/Documents/codebook/GSS%202021%20Codebook.pdf] ] -- .right-image[ ```r read_dta(...) # A tibble: 22 x 2 maeduc n <dbl+lbl> <int> 1 0 [no formal schooling] 55 2 1 4 3 2 7 ... 22 NA(d) 419 ``` ] --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 1. Do no harm use {haven} with labelled and tagged_na (foreign::read.dta also has an implementation) See {haven}'s "Conversion semantics" vignette for more information. .left-code[ ```r read_dta(...) %>% mutate( var_recoded = labelled(var, * c("Not applicable" = tagged_na("i"), * "No answer" = tagged_na("n"), * "Dont know" = tagged_na("d") )) ) ``` ] .right-image[ ```r # A tibble: 24 x 2 maeduc_recoded n <fct> <int> 1 0 55 2 1 4 3 2 7 ... 22 Dont know 316 23 Not applicable 100 24 No answer 3 ``` ] --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 1. Do no harm Formatting as data: use {openxlsx}, {tidyxl} to retain formatting information <img src="data:image/png;base64,#images/formatting-as-data.jpg" title="Screen shot of an Excel spreadsheet with some rows highlighted in yellow." alt="Screen shot of an Excel spreadsheet with some rows highlighted in yellow." width="50%" /> --- .slide-header[HOW TO BE A POLLINATO.strong[R]] </br> </br> </br> ## A bit of effort, a bit of empathy. ## Take care with other people's data. ## Do no harm. --- class: primary, inverse background-image: url(data:image/png;base64,#images/section-1-ws.png) background-size: cover # 2. Make things that just work --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 2. Make things that just work --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 2. Make things that just work .pull-left[ Outputting data ```r # Usual way write.csv(...) # Better way library(foreign) write.foreign(..., package = "SAS") ``` ] -- .right-image[ SAS script <img src="data:image/png;base64,#images/foreign-sas-script.jpg" title="SAS script generated by write.foreign function" alt="SAS script generated by write.foreign function" width="75%" /> ] --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 2. Make things that just work -- </br> </br> <img src="data:image/png;base64,#images/renv-example-01.png" title="Email message with text 'Hi Kiegan, looks like there is a hiccup. The server-hosted dashboard is not filtering based on the uploaded file. It is working on my local computer." alt="Email message with text 'Hi Kiegan, looks like there is a hiccup. The server-hosted dashboard is not filtering based on the uploaded file. It is working on my local computer." width="100%" /> -- </br> </br> <img src="data:image/png;base64,#images/renv-logo.png" title="renv package hex sticker." alt="renv package hex sticker." width="15%" /> .footnote[renv package: https://rstudio.github.io/renv/articles/renv.html] --- .slide-header[HOW TO BE A POLLINATO.strong[R]] </br> </br> </br> ## A bit of effort, a bit of empathy. ## A positive interaction. ## Things just work. --- class: primary, inverse background-image: url(data:image/png;base64,#images/section-1-ws.png) background-size: cover # 3. Promote growth --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 3. Promote growth Having newer R users interact with existing scripts and processes. -- .pull-left[ </br> <img src="data:image/png;base64,#images/dialog-example-01.png" title="Chat messages. Message 1: 'Can you describe the sequence of lines that you ran?' Message 2: 'So you ran 1-57, then changed overwrite_IU = TRUE, then ran 61-66, then ran 37-57?' Message 3: 'all in the same session'?" alt="Chat messages. Message 1: 'Can you describe the sequence of lines that you ran?' Message 2: 'So you ran 1-57, then changed overwrite_IU = TRUE, then ran 61-66, then ran 37-57?' Message 3: 'all in the same session'?" width="80%" style="display: block; margin: auto;" /> ] -- .pull-right[ {svDialogs} <img src="data:image/png;base64,#images/dialog-box.jpg" title="A dialog box pop-up in R asking the user if they would like to include NA values for a particular value in an analysis. The user can select 'yes' or 'no' in the pop-up box." alt="A dialog box pop-up in R asking the user if they would like to include NA values for a particular value in an analysis. The user can select 'yes' or 'no' in the pop-up box." width="70%" style="display: block; margin: auto;" /> ] .footnote[svDialogs package: https://cran.r-project.org/web/packages/svDialogs/svDialogs.pdf] --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 3. Promote growth <img src="data:image/png;base64,#images/shiny-example-01.png" title="A screenshot of a shinydashboard for building reports, with summary numbers at the top and a table showing all report submissions that need to be run." alt="A screenshot of a shinydashboard for building reports, with summary numbers at the top and a table showing all report submissions that need to be run." width="80%" style="display: block; margin: auto;" /> --- count: false .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 3. Promote growth <img src="data:image/png;base64,#images/shiny-example-02.png" title="A screenshot of a shinydashboard for building reports, showing buttons that analysts can select to run different R scripts related to a single report." alt="A screenshot of a shinydashboard for building reports, showing buttons that analysts can select to run different R scripts related to a single report." width="80%" style="display: block; margin: auto;" /> --- count: false .slide-header[HOW TO BE A POLLINATO.strong[R]] ### 3. Promote growth <img src="data:image/png;base64,#images/shiny-example-03.png" title="A message reading 'hey! I am honestly not sure how I caused this error. I thought I'd done everything in order. Have you seen it before?'" alt="A message reading 'hey! I am honestly not sure how I caused this error. I thought I'd done everything in order. Have you seen it before?'" width="90%" style="display: block; margin: auto;" /> -- <img src="data:image/png;base64,#images/shiny-example-04.png" title="A message reading 'Yeah, I definitely would be interested in what went wrong! I really want to get better at using R'" alt="A message reading 'Yeah, I definitely would be interested in what went wrong! I really want to get better at using R'" width="90%" style="display: block; margin: auto;" /> -- <img src="data:image/png;base64,#images/shiny-example-05.png" title="A message reading 'It is just saying PDF report failed. I am looking at the log right now. So far I only see warnings but I am goign to look for the error.'" alt="A message reading 'It is just saying PDF report failed. I am looking at the log right now. So far I only see warnings but I am goign to look for the error.'" width="90%" style="display: block; margin: auto;" /> --- .slide-header[HOW TO BE A POLLINATO.strong[R]] </br> </br> </br> ## A bit of empathy, a bit more effort. ## A learning opportunity. ## Promote growth. --- .slide-header[HOW TO BE A POLLINATO.strong[R]] ### ...how can you pollinate your own data workflows using R? -- .strong[Can you...] - do no harm? - make things that just work? - promote growth? </br> </br> </br> <img src="data:image/png;base64,#images/pollinator-bee-only.png" width="80%" style="display: block; margin: auto;" /> --- class: inverse background-image: url(data:image/png;base64,#images/thankyou-1-ws.png) background-size: cover .contact[ .strong[Kiegan Rice] Statistician rice-kiegan@norc.org @kieganer .strong[Weihuang Wong] Senior Research Methodologist wong-weihuang@norc.org @weihuang ]