class: left, bottom, title-slide # Part 2: Introduction to R ## #aectRTD workshop ### K. Bret Staudt Willet | Florida State University ### March 4, 2022 --- class: inverse, center, middle #
<br><br> Workshop Information --- #
Important Links ## Homebase - **Workshop website:** https://bretsw.github.io/aect22-workshop - **Workshop code repository:** https://github.com/bretsw/aect22-workshop - **tidytags R package:** https://github.com/ropensci/tidytags ## Agenda - **Part 1: Introduction to Networks** - Slides: [Part 1 - Networks](1-networks.html) - **Part 2: Introduction to R** - Slides: [Part 2 - R](2-intro-R.html) - **Part 3: Network Description** - Slides: [Part 3 - Description](3-description.html) - **Part 4: Network Inference** - Slides: [Part 4 - Inference](4-inference.html) ## Help - Ask questions in the Zoom chat! - Or, reach out directly: - Email: [bret.staudtwillet@fsu.edu](mailto:bret.staudtwillet@fsu.edu) - Twitter: [@bretsw](https://twitter.com/bretsw) --- class: inverse, center, middle #
<br><br> **Part 2:** <br> Introduction to R --- #
Our Constructivist Approach -- 1. We'll introduce some concepts 1. You'll try some code 1. We'll all discuss together -- <img src="img/tech_support_cheat_sheet.png" width="360px" style="display: block; margin: auto;" /> <div class="caption"> <p><a href="https://xkcd.com/627/" target="_blank">'Tech Support Cheat Sheet' from XKCD</a></p> </div> --- class: inverse, center, middle #
<br><br> Background <br> on R and RStudio --- #
Why learn R? -- - It is increasingly used in education -- - It is cross-platform, open-source, and freely-available -- - It is a programming language and quite flexible -- - It is capable of carrying out basic and complex statistical analyses -- - It is able to work with data small (*n* = 10) and large (*n* = 1,000,000+) efficiently -- - There is a great, inclusive community of users and developers --- #
Setting up R ### To download R - Visit [**cran.r-project.org**](https://cran.r-project.org/) to download R - Find your operating system (Mac, Windows, or Linux) - Download the 'latest release' on the page for your operating system and download and install the application ### To download RStudio - Visit [**rstudio.com**](https://rstudio.com/products/rstudio/download/) to download RStudio - Find your operating system (Mac, Windows, or Linux) - Download the 'latest release' on the page for your operating system and download and install the application --- class: inverse, center, middle #
<br><br> Try it out! --- #
Getting started with RStudio Activities: 1. Running a single RMarkdown chunk 1. Running another RMarkdown chunk 1. Rendering an RMarkdown document to a PDF 1. Creating your first visualization --- #
RMarkdown - RMarkdown is a data analysis "notebook" that combines text with code and output - It is a great file type to use when beginning to use R and to create reproducible analyses - It is fun to use because you can generate different types of output (Word, PDF, and even web-based) --- #
Looking at code What do you think this code will do? ```r starwars %>% filter(sex == "female") %>% select(name, hair_color, skin_color, homeworld) ``` --- #
Looking at code Let's see! ```r starwars %>% filter(sex == "female") %>% select(name, hair_color, skin_color, homeworld) ``` ``` ## # A tibble: 16 × 4 ## name hair_color skin_color homeworld ## <chr> <chr> <chr> <chr> ## 1 Leia Organa brown light Alderaan ## 2 Beru Whitesun lars brown light Tatooine ## 3 Mon Mothma auburn fair Chandrila ## 4 Shmi Skywalker black fair Tatooine ## 5 Ayla Secura none blue Ryloth ## 6 Adi Gallia none dark Coruscant ## 7 Cordé brown light Naboo ## 8 Luminara Unduli black yellow Mirial ## 9 Barriss Offee black yellow Mirial ## 10 Dormé brown light Naboo ## 11 Zam Wesell blonde fair, green, yellow Zolan ## 12 Taun We none grey Kamino ## 13 Jocasta Nu white fair Coruscant ## 14 Shaak Ti none red, blue, white Shili ## 15 Rey brown light <NA> ## 16 Padmé Amidala brown light Naboo ``` --- #
Looking at code What do you think this code will do? ```r starwars %>% filter(sex %in% c("male", "none"), height <= 150) %>% arrange(desc(height)) %>% select(name, sex, height, mass, homeworld) ``` --- #
Looking at code Let's see! ```r starwars %>% filter(sex %in% c("male", "none"), height <= 150) %>% arrange(height) %>% select(name, sex, height, mass, homeworld) ``` ``` ## # A tibble: 10 × 5 ## name sex height mass homeworld ## <chr> <chr> <int> <dbl> <chr> ## 1 Yoda male 66 17 <NA> ## 2 Ratts Tyerell male 79 15 Aleen Minor ## 3 Wicket Systri Warrick male 88 20 Endor ## 4 Dud Bolt male 94 45 Vulpter ## 5 R2-D2 none 96 32 Naboo ## 6 R4-P17 none 96 NA <NA> ## 7 R5-D4 none 97 32 Tatooine ## 8 Sebulba male 112 40 Malastare ## 9 Gasgano male 122 NA Troiken ## 10 Watto male 137 NA Toydaria ``` --- class: inverse, center, middle #
<br><br> Try it out! Hop over to [**Workspace 2**](workspace2.Rmd) --- class: inverse, center, middle #
<br><br> Quick Check In **(Five minutes in groups, five minutes together)** - What challenges did you encounter? - What successes did you have? - What questions remain? --- class: inverse, center, middle #
<br><br> Appendix: <br> Helpful Resources <br> and Troubleshooting --- # Resources **Beginners:** - [RStudio Beginners' Guide](https://education.rstudio.com/learn/beginner/) - Book: [*Data Science in Education Using R*](https://datascienceineducation.com) - See [Chapter 12](https://datascienceineducation.com/c12.html) - Walkthrough 6: Exploring Relationships Using Social Network Analysis With Social Media Data - [Physical copy of DSIEUR](https://www.routledge.com/Data-Science-in-Education-Using-R/Estrellado-Freer-Mostipak-Rosenberg-Velasquez/p/book/9780367422257) - [Even more resources from DSIEUR](https://datascienceineducation.com/c18.html) **Intermediates:** - [RStudio Intermediates' Guide](https://education.rstudio.com/learn/intermediate/) - [{tidytags} package notes](https://docs.ropensci.org/tidytags/index.html) - Book: [*R for Data Science*](http://r4ds.had.co.nz/) **Experts:** - [RStudio Experts' Guide](https://education.rstudio.com/learn/expert/) - Book: [*Learning Statistics with R*](https://learningstatisticswithr.com/) - [*Data Science in Education Using R*](https://datascienceineducation.com) - See [Chapter 20.3 Appendix C](https://datascienceineducation.com/c20.html#c20c) - Social Network Influence and Selection Models - SNA resources: [Dr. Ken Frank's website](https://sites.google.com/msu.edu/kenfrank/social-network-resources) --- # Troubleshooting - Try to find out what the specific problem is - Identify what is *not* causing the problem - "Unplug and plug it back in" - restart R; close and reopen R - Seek out workshops and other learning opportunities - Reach out to others! Sharing what is causing an issue can often help to clarify the problem - [RStudio Community forum](https://community.rstudio.com/) (highly recommended!) - Twitter hashtag: [#RStats](https://twitter.com/search?q=%23RStats&src=typeahead_click&f=live) - [Contact Bret!](http://bretsw.com) - General strategies on learning more: [Chapter 17 of *Data Science in Education Using R*](https://datascienceineducation.com/c17.html) --- class: inverse, center, middle #
<br><br> *Next up* <br> Part 3: <br> Network Description [`Part 3 slide deck here`](3-description.html)