R Intro (Winter 2024 / RSM456)
R is an open-source programming language for statistical computing and graphics. R is extensible, and has a large collection of high-quality user contributed packages that provides easy tools for common data analysis tasks. This 4-session workshop will introduce you the basics of R programming and data analysis.
What To Prepare
Please install R and RStudio Desktop before the first session.
If you encounter technical difficulties installing the software, you can instead create a free RStudio Cloud account so you can run R in the cloud via your browser.
An alternative to RStudio Cloud is the UofT JupyterHub/RStudio system. Go to its home page, choose the RStudio option, and click Log in to start. You will need your UTORid to login.
Session 1 Basics
- Slides
- Navigate RStudio
- Install and load R packages
- Load/import a tabular dataset into a dataframer/tibble
- R basic syntax (data and programming structures)
- Data
- Housing price (hprice.csv)
- Country risk (country_risk.xlsx)
- Code
- Reading list
- Hands-on Programming with R (Chapter 1 to 3; Chapter 4 to 7, 9 and 11; Appendix A, B and D)
Session 2 Descriptive Statistics, T-test, and Linear Regression
- Slides
- Descriptive statistics (mean, median, variance, etc.)
- T-test (
t.test()
) - Linear regression (
lm()
, read/interpret regression results)
- Code
Session 3 K-means Clustering
- Slides
- Code
Session 4 Logistic Regression
- Slides
- Code
Resources
- From Zero to Hero
- Step 1: Hands-on Programming with R (beginner level; learn R programming basics.)
- Step 2: R for Data Science (intermediate level; learn to manipulate, analyze and visualize data using R’s Tidyverse packages.)
- Step 3: Advanced R (advanced level; learn to master R.)
- Other Resources
- A Short R Tutorial by Germán Rodríguez
- R for Reproducible Scientific Analysis (from software carpentry)
- Programming with R (from software carpentry)
- R Graphics Cookbook
- ggplot2: Elegant Graphics for Data Analysis
- The R Graph Gallery (R graph samples with code)
- R Cheat Sheets (cheat sheets for many popular R packages)
- DoSStoolkit (self-paced interactive modules to help you learn and use R from Uoft Dept. of Statistical Science)
Back to TDMDAL Computing Page