Introduction to R (Self-Guided)

- Self Guided Classes
- 15 (Registered)
Are you ready to be a stats ninja? It all begins with knowing R. Why? Because knowing R gives you “control” over your data and your analyses, allowing you to make sense of your data. Not to mention that flexplot (the foundational tool in Simplistics) is best used in R. And, using R keeps a “record” of all your analyses, promoting an “open science” approach to research.
This course is the first step toward your becoming a stats Jedi master. This introductory R course teaches you the basics of all you need to know to begin using R to analyze/clean/manipulate your own data. Our introductory units begin by teaching:
• Why R is superior to every other stats software
• How to download and install R
• How to download and install RStudio
• Why and how to use R “packages”
• How to import datasets\
Then we will cover the basics of “base R” including:
• What is base R?
• Object types (data frames, vectors, characters, booleans)
• Creating objects
• Conditional statements
• Subsetting
We’ll also cover some very basic analyses, including:
• Visualizing data with flexplot
• Fitting models with lm
And finally, the crew-de-la-crop, the final unit will cover data manipulation. (Because not every dataset is ready for analysis). This unit will leverage the “tidyverse,” and will cover:
• What is the tidyverse?
• What are tidy data?
• The basic dplyr functions (mutate, summarize, filter, select)
• Creating sum scores
• Pivoting and merging
The salesman in me wants to say this course is all you need to be an R master; that you will become R proficient after just four weeks, and that all your greatest dreams will come true. The last statement is probably true, but the first two aren’t. This class is an introduction and by the end you will feel confident about doing some things, but there will be gaps in your understanding. (There are gaps in MY understanding and I’m a freaking genius!) But, you will reach the “Google point,” which is the point at which you have gained enough of a foundation that whatever you don’t know, you can at least Google it (or Chat GPT it?).
So, are you ready to begin an epic adventure? Fear not, wary traveler, lace up your boots and let’s get this party started!
Course Format
This course offers everything you need to master the material. Every unit has one to two lesson plans, and within the lesson plan are the following:
• Learning objectives. This is always a great idea to refer to this so you don’t get lost in the details. This tells you what the main “take-home” messages are.
• YouTube video tutorials. These videos have been curated (or created) to specifically address the topic of the unit.
• Assigned reading. Some of these readings will be from my textbook, while others will be from papers in the literature. Often these are designed to give greater breadth to what the videos cover.
• Quizzes. Every Unit has its own quizzes that allow you to test your own know-how and evaluate your own progress. If you’re mastering the quizzes, you’re mastering the information!
• Discussion boards. These discussion boards are there for you to gain additional clarification on the topics presented. Don’t be shy! Chances are whatever question you have, someone else has had.
While none of the above are required, you are paying for the course, so it would be wise to make sure you watch all videos, complete all readings, take all quizzes, and post your questions on the discussion board.
This course is an “on-demand” course, meaning you take it at your own pace.
Curriculum
- 7 Sections
- 21 Lessons
- Lifetime
- Canvas Resources – Introduction to R1
- Unit 1 Overview - Getting Started with R
Objectives
- RStudio
- R vs. SPSS
- R vs. RStudio
- Script vs. console
- How to install R Packages
- Workflow
- Basics in R
- data frames, vectors, numeric, characters, logical, factors
- with $, with indices, with names
- what it is, how to recognize one, documentation, arguments
- how to use c, data.frame, ls, sum, mean, head, str, flexplot
- Objects
- Workspaces
- The “Final Paper” idea
- Commenting
- Data types
- Subsetting
- Functions
- Additional resources:
- Getting Started with R
- R Basics (section 2.1-2.9)
6 - Unit 2 Overview - Basics of R
Objectives
- How to install R Packages
- Functions
- what it is, how to recognize one, documentation, arguments
- how to use c, data.frame, ls, sum, mean, head, str
- Three ways to import a dataset
- What do you do after importing dataset through file menu?
Instructions
- Read Getting Started with R
- Read R Basics (section 2.1-2.9)
- Watch the following videos:
3 - Unit 3 Overview - LMs, Flexplot, and Debugging
Objectives
- Three reasons we favor lm’s over t-tests/ANOVAs
- Know how to use LMs to fit ANOVAs and t-tests
- Know the functions summary, anova, estimates, and visualize
- Understand Flexplot’s guiding philosophy
- Know how to produce histograms, bar charts, scatterplots, panel plots, and bees warm plots
- Understand the flexplot formula and what each controls
- Anatomy of an error message
- Five steps to debugging
- Know what various error messages mean
Additional Resources
- Read the Flexplot manual (Note: you don’t need to read all of it. Just read pages 1-17).
4 - Unit 4 Overview - Basics of dplyr
Objectives
- tidyverse vs. R's way of doing things
- what filter, arrange, select, mutate, and summarize do
- selecting a range of columns (e.g., x1:x10)
- selecting "not" columns (e.g., -(x1:x10))
- understand auxiliary functions:
- starts_with, ends_with, contains, group_by, desc
- understand comparisons (&, |, ==, !=, %in%)
- Two old ways of doing things (creating throwaway objects vs. nested functions)
- Advantage of the pipe operator
- How to read code with pipe operator
- How to use the pipe operator with filter, select, mutate, etc.
Additional Resources
- Read the Wickham and Groleman, Chapter 5
3 - Unit 5 Overview - Advanced dplyr
Objectives
- know how to use recode
- rules for going from numbers to characters and vice versa
- how to use across
- arguments for across
- rules for specifying a function with across
- know what across does
- what rowSums does
- what arguments rowSums requires
- how to use rowSums within mutate
- why we need multiple mutate statements
Additional Resources
- Read the Wickham and Groleman, Chapter 5
6 - Unit 6 Overview - Pivoting
Objectives
- Understand what tidy data are
- Two reasons we need to pivot
- Four arguments required for the pivot_longer function
- what complications non time-varying complications add
- know what time varying variables are
- Know how to use starts_with, ends_with, etc for pivoting
- Know how to use gsub
- Two ways to merge datasets
Additional Resources
- Read the Wickham and Groleman, Chapter 12
4