credentials::ssh_setup_github()Lab 00: Getting Started
Please complete all of today’s lab tasks before leaving lab today.
Introduction
The goal of today’s lab is to briefly introduce you to the computing tools we’ll use in this course, set up your computing access, and complete the entry survey. We’ll talk more about these tools in upcoming labs.
A container is a self-contained copy of RStudio for you, and you alone. All your computing for this course happens inside it — no installation, no version mismatches between sixteen different laptops.
Computing setup
RStudio
R is the name of the programming language itself and RStudio is a convenient interface.
Reserve your RStudio container
- Go to https://cmgr.oit.duke.edu/containers. Log in with your Duke NetID credentials.
- Click “Reserve STA119” to reserve an RStudio container.
You only need to reserve a container once per semester.
Open your RStudio container
- Go back to https://cmgr.oit.duke.edu/containers and log in again if needed.
- Click
STA119to open the container. You should now see the RStudio environment in your browser, with a Console pane showing a>prompt.
Git and GitHub
In addition to R and RStudio, we’ll use Git and GitHub for version control.
Git is a version control system (like “Track Changes” in Microsoft Word, but far more powerful) and GitHub is the home for your Git-based projects on the internet (like Dropbox, but much better — and it makes collaboration visible).
Sign up for a GitHub account
You’ll need a GitHub account to access the assignments and labs for this course.
- If you don’t have one, go to github.com and create one.
- If you already have an account, log in right now and confirm you know your credentials.
Click here for advice on choosing a username — it’s a professional account you may still be using in ten years.
Connect RStudio and GitHub
Now that you have RStudio and a GitHub account, we’ll configure Git so RStudio and GitHub can talk to each other.
Set up your SSH key
You’ll authenticate to GitHub using SSH. Follow along on the projector for this one — it’s the step most likely to go sideways, and it’s much easier to fix while everyone does it together.
You only do this once. Once the key exists, it keeps working — you won’t repeat this in any later lab.
Type this in the Console and press Enter:
- Step 1: It asks “No SSH key found. Generate one now?” — press 1 for yes.
- Step 2: It generates a key (starting
ssh-rsa...), then asks “Would you like to open a browser now?” — press 1. - Step 3: You may be asked for your GitHub username and password.
- Step 4: On the GitHub page that opens, paste the key into the box and give it a name — anything recognizable works, e.g.
histstat-container. - Step 5: Click the button to add the key.
Configure Git to introduce yourself
Git labels every change with who made it, so it needs your name and email address.
To do so, you will use the use_git_config() function from the usethis package.
Type this in the Console, with your own details substituted in:
usethis::use_git_config(
user.name = "Your name",
user.email = "Email associated with your GitHub account"
)For example, mine would be:
usethis::use_git_config(
user.name = "Kat Husar",
user.email = "kat.husar@duke.edu"
)Use the exact same email you used to create your GitHub account. If these differ, Git and GitHub won’t connect your work to your account — the symptom is confusing rather than obvious.
Nothing visible happens, which is unnerving. To check: click the Terminal tab (next to Console) and type:
git config user.name
git config user.emailEach should echo back exactly what you typed. If there’s a typo, just run use_git_config() again with the correction — the last one wins.
Clone your first repository
A repository (“repo”) is a collection of files hosted on GitHub. Copying one down to your container is called cloning.
Today’s repo is public, and there’s nothing to commit or push yet — that starts in Lab 01, which gets a full walkthrough of its own. Today is purely: does the pipeline work end to end, and can you read an error message?
- Go to https://github.com/statistical-history/lab-00.
- Click the green Code button. Choose SSH (it may already be selected — the label reads Clone with SSH), then click the clipboard icon to copy the address. It should start with
git@github.com:, nothttps://. - In RStudio: File → New Project → Version Control → Git.
- Paste the address into Repository URL. Leave the directory name as it fills in.
- Click Create Project.
The first time your container talks to GitHub, you may see a message asking whether you trust the host — “the authenticity of host github.com can’t be established.” Type yes and press Enter.
https:// address
Go back and switch it to SSH. An https:// address will ask for a password on every single operation and will not accept your GitHub password — this is the single most common way this step fails.
RStudio will clone the repo and open it as a project. You should see its files in the Files pane, bottom right.
That’s the whole skill. You’ll clone about one repo a week for the rest of the semester, and after the third time you’ll stop thinking about it.
Submit GitHub username
Use the link below to submit your GitHub username and confirm that you (1) have access to an RStudio container and (2) have completed the steps to configure git and send files between RStudio and GitHub.
Tell me who you are
Fill in the entry survey: https://forms.cloud.microsoft/r/uwjPAKK6rZ
This survey will help me learn more about you, your interests, and your previous statistics and computing experience.
Done
You now have a container, a GitHub account, a working SSH key, a configured Git, and a cloned repository.
Next week: pull, commit, push, and the first real data — Mayer’s 27 equations.
Come to office hours or send a message — don’t spend an evening fighting this alone, and don’t skip Lab 0! Every later lab assumes today’s setup works, so a broken setup is the one problem worth interrupting me about.
If you finished early: help the person next to you. That’s not extra credit, it’s how today goes well for everyone.