class: left, bottom, title-slide # Part 1: Introduction to R ## #AECT20 workshop ### K. Bret Staudt Willet, Spencer P. Greenhalgh, & Joshua M. Rosenberg ### October 30, 2020 --- class: inverse, center, middle # Welcome & Introductions --- # Meet Your Instructors! ### Bret Staudt Willet, ABD - Ph.D. Candidate, Educational Psychology & Educational Technology, Michigan State University - http://bretsw.com - Twitter: [@bretsw](https://twitter.com/bretsw) -- ### Spencer Greenhalgh, Ph.D. - Assistant Professor, Information Communication Technology, University of Kentucky - https://spencergreenhalgh.com - Twitter: [@spgreenhalgh](https://twitter.com/spgreenhalgh) -- ### Josh Rosenberg, Ph.D. - Assistant Professor, STEM Education, University of Tennessee, Knoxville - https://joshuamrosenberg.com - Twitter: [@jrosenberg6432](https://twitter.com/jrosenberg6432) --- # Meet Your Co-conspirators! ## https://padlet.com/bretsw/aect20workshop <img src="img/hello.jpg" width="560" style="display: block; margin: auto;" /> --- class: inverse, center, middle # Session Information --- # Important Links ## Homebase - **Workshop website:** https://bretsw.github.io/aect20-workshop - **RStudio Cloud workspace:** https://rstudio.cloud/project/1820768 - **tidytags R package:** https://bretsw.github.io/tidytags ## Agenda - **Part 1: Introduction to R** - Slides: [Part 1 - Setup](1-intro-slides.html) - **Part 2: Twitter Research Workflow** - Slides: [Part 2 - Workflow](2-workflow-slides.html) --- # Need help? Reach out! - Ask questions in the Zoom chat! - Or, reach out directly: - Email: [staudtwi@msu.edu](mailto:staudtwi@msu.edu) - Twitter: [@bretsw](https://twitter.com/bretsw) | [@spgreenhalgh](https://twitter.com/spgreenhalgh) | [@jrosenberg6432](https://twitter.com/jrosenberg6432) --- # 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="360" style="display: block; margin: auto;" /> --- class: inverse, center, middle # Background 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 --- class: inverse, center, middle # Where You'll Be Running R RStudio Cloud (preferred) OR R + RStudio locally on your computer --- # Option 1: RStudio Cloud [`Workshop Project Space in RStudio Cloud`](https://rstudio.cloud/project/1820768) - Link also here: https://rstudio.cloud/project/1820768 -- - Once you have navigated to this webpage, log in using a Google or GitHub account. -- - Then, create a permanent copy of the project in your own workspace (see the prompt at the top of the page guiding you to do this). -- - From here, you can write and run R code exactly as you would through RStudio on your computer. --- # Option 2: R + RStudio Locally ### 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 # 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 x 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(desc(height)) %>% select(name, sex, height, mass, homeworld) ``` ``` ## # A tibble: 10 x 5 ## name sex height mass homeworld ## <chr> <chr> <int> <dbl> <chr> ## 1 Watto male 137 NA Toydaria ## 2 Gasgano male 122 NA Troiken ## 3 Sebulba male 112 40 Malastare ## 4 R5-D4 none 97 32 Tatooine ## 5 R2-D2 none 96 32 Naboo ## 6 R4-P17 none 96 NA <NA> ## 7 Dud Bolt male 94 45 Vulpter ## 8 Wicket Systri Warrick male 88 20 Endor ## 9 Ratts Tyerell male 79 15 Aleen Minor ## 10 Yoda male 66 17 <NA> ``` --- # Try it out! Let's hop over to the **Workspace for Part 1**! - [Working in RStudio Cloud](https://rstudio.cloud/project/1820768) - [Working locally](1-intro-workspace.Rmd) --- class: inverse, center, middle # Discuss in groups! **(Five minutes in groups, five minutes together)** - What challenges did you encounter? - What successes did you encounter? - What questions do you still have? --- class: inverse, center, middle # *Next up*: Part 2: Twitter Research Workflow [`Part 2 slide deck here`](2-workflow-slides.html) --- class: inverse, center, middle # Appendix: Helpful Resources and Troubleshooting --- # Resources - {tidytags} package notes: https://bretsw.github.io/tidytags/ - [Beginners' Guide from RStudio](https://education.rstudio.com/learn/beginner/) - Book: [*R for Data Science*](http://r4ds.had.co.nz/) - Book: [*Data Science in Education Using R*](https://datascienceineducation.com) - [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) - Book: [*Learning Statistics with R*](https://learningstatisticswithr.com/) --- # 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 - Consider using RStudio Cloud - 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 - https://community.rstudio.com/ (highly recommended!) - Twitter hashtag: #rstats - Contact Bret, Spencer, and Josh! - General strategies on learning more: https://datascienceineducation.com/c17.html