+ - 0:00:00
Notes for current slide
Notes for next slide

Lab 01: R you Ready?

2019-08-29

1 / 19

Welcome to lab

2 / 19

Agenda

  • Follow up
  • Meet the toolkit
  • Demos
  • Lab 01 on your own
3 / 19

Join campuswire

Go to bit.ly/sta-212-f19-discuss-join and sign up.

4 / 19

Practice answering a question or posting in a channel

  • Click on "Class feed" on the top left. You should see a post from me titled Hello!
  • Practice responding to this post, up-voting it, etc.
  • Click on "Rooms" then #general
  • Practice posting here - post a fun fact about your self, respond with an emoji 👍, etc
5 / 19

Toolkit

toolkit

  • Scriptability \(\rightarrow\) R
  • Literate programming (code, narrative, output in one place) \(\rightarrow\) R Markdown
6 / 19

R and RStudio

7 / 19

What is R/RStudio?

  • R is a statistical programming language
  • RStudio is a convenient interface for R (an integreated development environment, IDE)
  • At its simplest:
    • R is like a car’s engine
    • RStudio is like a car’s dashboard

➥ Source: Modern Dive

8 / 19

Let's take a tour - R / RStudio

Concepts introduced:

  • Console
  • Using R as a calculator
  • Environment
  • Loading and viewing a data frame
  • Accessing a variable in a data frame
  • R functions
9 / 19

R essentials

A short list (for now):

  • Functions are (most often) verbs, followed by what they will be applied to in parantheses:
do_this(to_this)
do_that(to_this, to_that, with_those)
10 / 19

R essentials

A short list (for now):

  • Functions are (most often) verbs, followed by what they will be applied to in parantheses:
do_this(to_this)
do_that(to_this, to_that, with_those)
  • Columns (variables) in data frames are accessed with $:
dataframe$var_name
10 / 19

R essentials

A short list (for now):

  • Functions are (most often) verbs, followed by what they will be applied to in parantheses:
do_this(to_this)
do_that(to_this, to_that, with_those)
  • Columns (variables) in data frames are accessed with $:
dataframe$var_name
  • Packages are installed with the install.packages function and loaded with the library function, once per session:
install.packages("package_name")
library(package_name)
10 / 19

tidyverse

  • The tidyverse is an opinionated collection of R packages designed for data analysis and data science.
  • All packages share an underlying philosophy and a common grammar.
11 / 19

R Markdown

12 / 19

R Markdown

  • Fully reproducible reports -- each time you knit the analysis is run from the beginning
  • Simple markdown syntax for text
  • Code goes in chunks, defined by three backticks, narrative goes outside of chunks
13 / 19

Let's take a tour - R Markdown

Concepts introduced:

  • Copying a project of mine
  • Knitting documents
  • R Markdown and (some) R syntax
14 / 19

Happy Little Clouds Example

15 / 19

Happy Little Clouds Example


  • Go to RStudio Cloud and click on Happy Little Clouds Example
  • Open and knit the R Markdown document.
15 / 19

R Markdown help

Markdown Quick Reference
Help -> Markdown Quick Reference

16 / 19

Workspaces

Remember this, and expect it to bite you a few times as you're learning to work with R Markdown: The workspace of your R Markdown document is separate from the Console!

  • Run the following in the console
x <- 2
x * 3
17 / 19

Workspaces

Remember this, and expect it to bite you a few times as you're learning to work with R Markdown: The workspace of your R Markdown document is separate from the Console!

  • Run the following in the console
x <- 2
x * 3

All looks good, eh?

17 / 19

Workspaces

Remember this, and expect it to bite you a few times as you're learning to work with R Markdown: The workspace of your R Markdown document is separate from the Console!

  • Run the following in the console
x <- 2
x * 3

All looks good, eh?

  • Then, add the following chunk in your R Markdown document
x * 3
17 / 19

Workspaces

Remember this, and expect it to bite you a few times as you're learning to work with R Markdown: The workspace of your R Markdown document is separate from the Console!

  • Run the following in the console
x <- 2
x * 3

All looks good, eh?

  • Then, add the following chunk in your R Markdown document
x * 3

What happens? Why the error?

17 / 19

How will we use R Markdown?

  • Every assignment / report / project / etc. is an R Markdown document
  • You'll always have a template R Markdown document to start with
  • The amount of scaffolding in the template will decrease over the semester
  • You will turn in the .html file on Sakai
18 / 19

Lab 01

  • Lab instructions are posted on the course website under </>
    • Let's go find today's!
19 / 19

Welcome to lab

2 / 19
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow