Main Ideas

Coming Up

Tour of R and RStudio

Let’s take a tour of R and RStudio. I’ll do a short demo, then give you a few minutes to try out yourself.

Concepts introduced

Use R as a calculator by typing the following in the console.

3 * 5 + 10
x <- 3
x + x^2
x <- 1:10
x*7

Git and GitHub

Concepts introduced: - Clone a GitHub repo and make a new RStudio project - Configure Git - Working with a local and remote repository - Making a change locally, committing, and pushing - Making a change on GitHub and pulling

Configuring SSH and GitHub

Until last August, you could use a user name and password to log into GitHub. GitHub has deprecated using a password in that way. Instead, we will be authenticating GitHub using public/private based keys. This is a short overview for how to do authenticate in this way.

  1. First, type credentials::ssh_setup_github() into your console.
  2. Second, R will ask “No SSH key found. Generate one now?” You should click 1 for yes.
  3. Third, you will generate a key. It will begin with “ssh-rsa….” R will then ask “Would you like to open a browser now?” You should click 1 for yes.
  4. Fourth, you may be asked to provide your username and password to log into GitHub. This would be the ones associated with your account that you set up. After entering this information, you should paste the key in and give it a name.

You should not have to do this every time.

Your turn!

The link for today’s application exercise is at: https://classroom.github.com/a/KBJlnRKM.

  • Click on the green CODE button, select Use SSH (this might already be selected by default, and if it is, you’ll see the text Clone with SSH). Click on the clipboard icon to copy the repo URL.

Clone the repo and make a new project in RStudio.

You should see the files for the Flint Water Crisis analysis in the Files pane.

Configure git by running the following code in the terminal. Fill in your GitHub username and the email address associated with your GitHub account.

git config --global user.name 'username'
git config --global user.email 'password'

This you will have to do more often.

Open the RMarkdown file ae02-flint.Rmd. We will use that for the next part of class. There is also an ae02-flint.html file.

Put your name for the author, then knit the document.

Select all of the updated files in the Git pane, click to commit and write the commit message “Updated author name”.

Click to push your changes.

If you refresh your repo on GitHub, you will see the updated files with your commit message.

Flint Water Crisis analysis

Follow along with the instructions in app-02-flint.Rmd. An html version of the file can be found in the repo as well.

Submitting application exercises

Once you have completed the activity, push your final changes to your GitHub repo! Make sure your repo is updated on GitHub, and that’s all you need to do to submit application exercises for participation.