Welcome to STA 199

Lecture 2

Dr. Elijah Meyer + Konnie Huang

Duke University
STA 199 - Fall 2022

August 31, 2022

Checklist

– Have you made a GitHub account?

– Are you on Slack? (If not, this is okay. We will figure this out. Try the new link on the Sakai announcement)

– Have you reserved a Duke container?

– Have you filled out the Getting to know you survey? (If not, please do this now)

— When putting in your github user name, please only put your name and no other text (e.g., My username is …). If you did this, please go back and re-answer this question.

— If you have filled out the survey, you will see an invite to my repo (in email and on github.com). you NEED to accept this invite so I can create your lab-0 assignment.

Warm Up Question

Please think through / write down what each line of code would produce.

Tip (and good practice): if you have questions about a function, use ?function.name to pull up the help page! If the help page is not helpful, look at their examples section and click Run Examples.

Goals for today

  • R and RStudio
  • Quarto Documents
  • More Practice
  • Train your brain.

What is R and RStudio?

– R is a statistical programming language

– RStudio is a convenient interface for R

Some R essentials

Functions are (normally) verbs, followed by what they will be applied to in parentheses:

Some R essentials

Columns (variables) in data frames are accessed with $

Packages are installed with the install.packages function and loaded with the library function, once per session:

tidyverse

– The tidyverse is a collection of R packages designed for data science.

– All packages share an underlying philosophy and a common grammar.

GitHub

– We have set up an account and cloned repos

– Let’s clone ae-01

– As said on day 1, GitHub is set up for version control (more coming on Thursday)

GitHub Commands: Pull Commit Push (Thursday Prep)

GitHub Commands: Pull Commit Push (Thursday Prep)

GitHub Commands: Pull Commit Push (Thursday Prep)

General GitHub Tips

– Stay away from the terminal. If you google for help, skip any methods for using git through the command line.

– There is a great resource for working with git and R: happygitwithr.com

— Some of the content in there is beyond the scope of this course, but it’s a good place to look for help.

Quarto

– an open-source scientific and technical publishing system

– publish high-quality articles, reports, presentations, websites, blogs, and books in HTML, PDF, MS Word, ePub, and more

– Code goes in chunks, defined by three backticks, narrative goes outside of chunks

How will we use Quarto?

– Every assignment / lab / project will be given to you and turned in as a Quarto document

– You will always have a Quarto template document to start with

– As we get more familiar with R, the more code you will construct on your own

Try It

Click on the ae-01 qmd file and render it

Self-Check

– What is version control? Why is it important?

– What is R vs RStudio?

– What is Quarto?

In-Class

Let’s get into ae-01