Introduction to R

JHSPH

Class:

  • 8:30AM-11:50PM in W3008 on June 11-15

Grading

  1. Attendance/Participation: 20%
  2. Nightly Homework: 3 x 15%
  3. Final “Project”: 35%

Example Projects

Example projects can be found with the source code: Rmd, and the output Docx here.

Example knitr

Rmd and html output

All the Requirements in this Course

Packages

We have an R package called jhur that will make sure all the packages are installed.

install.packages("remotes")
remotes::install_github("muschellij2/jhur")

Alternatively, all the packages used (in any way - homework, lecture, lab), are listed in this text file. If you would like to install all the packages from this file, please download that text file and run this R script.

Functions

All the functions used (in any way - homework, lecture, lab), are listed in this CSV file, which can start a kind of cheat sheet for you.

Data

All the data used that are not specifically to be downloaded from the web are located in this zip file, but we will show you how to read data from the internet as well.

Schedule

Module Slides Code Resource In Class Work
Day 0
Homework 1 Data Camp
Day 1
Intro HTML, PDF R, Rmd
RStudio HTML, PDF R, Rmd
Basic R HTML, PDF R, Rmd Lab, Key
Data IO HTML, PDF R, Rmd Lab, Key
Homework 2 R, Key
Day 2
Subsetting Data in R HTML, PDF R, Rmd Lab, Key
Data Summarization HTML, PDF R, Rmd Lab, Key
Day 3
Data Classes HTML, PDF R, Rmd Lab, Key
Data Cleaning HTML, PDF R, Rmd Lab, Key Live R file
Homework 3 R, Key
Day 4
Manipulating Data in R HTML, PDF R, Rmd Lab, Key Live R file
Data Visualization HTML, PDF R, Rmd Lab, Key Live R file
Day 5
Statistics HTML, PDF R, Rmd Lab, Key Live R file
Functions HTML, PDF R, Rmd
Knitr HTML, PDF R, Rmd

Live Code Examples

Code Example Script
Replacing with ifelse in dplyr replace_if.R
Relevant to hw2: Fixing problems in read_csv with col_types read_csv_specifications.R
Multiple Summarization (mean/sd) and summarize with quantile mean_sd_number_of_non_missing.R
Changing Factors in Stata file stata_factors.R
Tables and Figures in RMarkdown tables_and_plots.Rmd

PDF of black and white theme

Shiny and Knitr Docs

Online Videos of Lectures

From Winter Institute 2018

Day Link to Video
Data Summarization https://youtu.be/l-r4RBhNDDo

From Summer Institute 2 2017

Day Link to Video
Day 1: Part 1 https://youtu.be/QdD6x3tDI5Y
Day 1: Part 2 https://youtu.be/GMBfu_bnKOI
Day 2 https://youtu.be/NQFAoxX-w74
Day 3: Part 1 https://youtu.be/OEv1ZZXvToY
Day 3: Part 2 https://youtu.be/OEbgC3A5vKw
Day 4: Part 1: Strings https://youtu.be/D6QDXDlKaWs
Day 4: Part 2: Strings https://youtu.be/8pVPMZugn6E
Day 5

Find an Error!?

Feel free to submit typos/errors/etc via the github repository associated with the class: https://github.com/muschellij2/intro_to_r

This page was last updated on 2018-06-15 12:10:54 Eastern Time.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.