Getting Started
You can never look at the data too much. – Mark Engerman
The world confronts us. Make decisions we must.
We do all of our data science in the cloud, using GitHub Codespaces with Visual Studio Code (VS Code).
In this chapter you will sign up for GitHub, create a Codespace, and learn about tutorials. Everything runs in your browser. You don’t install anything on your own machine. Tutorials are the standard format we use for homework assignments. They allow you to work at your own pace
Your answers to the questions on this page save automatically in your browser, so you can close the page and come back later without losing anything. If you ever want to wipe them all and begin again, click the Start Over button in the right-hand sidebar.
Start by telling us who you are. Your instructor might also ask you to fill in the “ID” field so that your work can be matched to a grading database. If not, leave the “ID” field blank. Fill in the fields below and click Submit. You can edit your answers.
How to take a screenshot
Many questions in this chapter ask you to paste a screenshot as proof that you did something. Take the screenshot first, then click into the question’s answer box and paste it with Ctrl + V (Windows, Chromebook) or Cmd + V (Mac). There is no upload button. A preview of your screenshot appears in the box when it has worked. Then click Submit Answer.
The easiest way to acccomplsh this is to copy the screenshot to your clipboard, so that you can paste it right away:
Windows: press
Windows + Shift + S, then drag a box around what you want to capture. The screenshot is copied to your clipboard.Mac: press
Cmd + Control + Shift + 4, then drag a box around what you want to capture. AddingControlis what copies the screenshot to your clipboard. Without it,Cmd + Shift + 4saves a file to your Desktop instead, which you cannot paste.Chromebook: press
Ctrl + Shift + Show windows(the key with a rectangle and two lines on it), drag a box around what you want to capture, and click Copy to clipboard in the notification that appears.
The screenshot should capture enough of the screenthat we can confirm that you followed our instructions.
Use either Chrome or Edge
In theory, the below instructions work in any browser. In practice, we have found that the best experience is with either Chrome or Edge. If you are not using either Chrome or Edge, then install one of them now: Chrome or Edge. We recommend Chrome.
Once you have Chrome (or Edge) installed, start it. Paste a screenshot of it below. Make sure that the screenshot includes the name of the browser, probably best captured from the menu.
Your screenshot should look similar to this.

GitHub
Click here and sign up for a GitHub by using the green button. Use your school email address for this account, if you are a student.
Useful advice for choosing a username includes using your real name, so people know who they are dealing with and can guess or remember it easily; making sure it is something you would be comfortable showing a future boss; keeping it short, and making it as unique as possible in as few characters as you can. Finally, make it timeless by avoiding references to your current university, employer, or home town.
Once you have signed up for GitHub and are signed in to GitHub, go to github.com/ followed by your username, and click the Overview tab. Your screenshot should look similar to this.

The GitHub Student Developer Pack provides all sorts of perks, but you must visit that page to turn on the benefits. It confirms your student status on the basis of you having an email account at your school.
If you are a student, go to that page now, sign in, and apply for the benefits. When you finish, GitHub tells you that your application has been submitted. Your screenshot should look similar to this. (If you are not a student, skip this question.)

On GitHub, your projects are organized into “repositories,” usually called “repos.”
A throwaway Codespace
You create a new Codespace using the https://github.com/PPBDS/codespace-starter repository. We refer to this repo as codespace-starter.
Go to https://github.com/PPBDS/codespace-starter.

This Codespace is for learning the platform, not for your permanent work.
GitHub gives every account 60 free Codespaces hours per month. Free hours are not infinite, however, so it is your responsibility to stop (and delete) Codespaces you are no longer using.
Launching the Codespace
Click the green Code button at the top right of the repository page, switch to the Codespaces tab, and click “Create codespace on main.”

This will take a minute or so. Behind the scenes, GitHub is creating a virtual machine in the cloud with all the necessary tools for doing data science. That machine is called a “Codespace.”
You may be asked: “Do you trust the authors of the files in this folder?”

Click to agree.
Once the process is done, a banner message appears announcing “✅ YOUR CODESPACE IS READY.”

GitHub gives your Codespace a randomly generated name. Mine is “cuddly space giggle”, but yours will be different. The name appears in four spots: the address bar of your browser, the box at the top center of VS Code, the top of the Explorer panel on the left, and the blue button at the bottom left.

Touring the workspace
VS Code is an integrated development environment (IDE) for coding and data science. Highlights:
This Codespace is in the cloud. The URL will be a combination of the GitHub-determined human-readable but somewhat nonsensical name —
cuddly space gigglein my case — and a bunch of letters and numbers. There is no need to remember this URL. GitHub keeps track of things. You can see all your current Codespaces athttps://github.com/codespaces.In the upper right-hand corner are the “Customize Layout …” buttons. These are part of the VS Code “Title Bar.” Since we aren’t using the AI tools right now, it often makes sense to close the “Chat” window, which appears on the right side of the screen. You can close this in two ways: Click the “X” mark or click the “Toggle Secondary Side Bar” button, the furthest right-hand button. You can then bring the Chat window back by clicking the “Toggle Secondary Side Bar” button again. Try it now.

The “Activity Bar” is the narrow vertical strip on the far left with icons for Explorer, Search, Source Control, Extensions, etc.
The “Editor” is the large central area where you edit files.
The “Panel” is the horizontal area below the Editor, containing the Problems, Output, Debug Console, Terminal, and Ports views. Our main focus is the Terminal view. This is where we “talk” to both the (cloud) computer itself and to the R program that it provides.

You can start new bash Terminals by clicking on the + sign above the list of terminals. Do so now. As you can see below, you now have two bash Terminals. You switch by selecting the one you want to work with from the list. You can type commands at the “prompt,” which is where the red arrow is pointing below.

If you hover your cursor over the terminal list, a split-screen and a trash can appear. Clicking on the trash can will close the terminal.

The language can be a little confusing. There is a capital T “Terminal” view, which is one of the tabs across the top of the Panel. In that Terminal view, we can work with many individual small T “terminals” of various sorts. So far, you have only seen bash Terminals, which get a capital T because they are a type of named terminal. The bash shell is a program that lets you “talk” to the computer itself.
In addition to bash Terminals, we can also start an R session under the Terminal. Instead of clicking the + sign, click the small downward-pointing arrow next to it. This will show a variety of options.

Select “R Terminal.” This will start an R session that lets you “talk” to R in the same way that a bash shell allows you to talk to the computer.
Click on the “R Interactive” tab which should appear beneath the other terminals on the right side of the Panel.
Type in 2 + 2 at the R prompt and hit enter (Windows) or return (Mac). (Going forward we will just use Enter to refer to this action. Mac users should hit return.)

An IDE like VS Code is designed to help us organize our work. We need to talk to the computer via the bash Terminal (a terminal running the bash shell), talk to R, view plots, and so on.
At the R Terminal, run plot(1:10). We use the terms “run” and “execute” interchangeably. They both indicate that you should type the command at the appropriate terminal and hit Enter.

Data scientists make lots of plots.
Click into the bash Terminal, type pwd, and then press Enter.

Copy and Paste both the Command and the Response from the bash Terminal into the box below. We abbreviate this instruction as CP/CR.
We typically provide example answers, like the one below, after you submit your own response. Do not be concerned if your answer differs from the example we show.
codespace-starter $ pwd
/workspaces/codespace-starter
codespace-starter $
Also, we generally do not allow you to edit answers once you have submitted them. If you make a mistake, don’t worry! Tutorials are graded Pass/Fail.
pwd stands for print working directory: it shows the directory in which the terminal is working. The response confirms that you are inside your Codespace, a complete computer running in the cloud. It is OK if your formatting differs from ours. What matters is that you show that you ran the command as instructed.
That is the usual process: run something in a terminal, copy the command and the response, paste them into the answer box. Almost every exercise in every later tutorial works this way.
Your answers
At the end of every tutorial, you download a copy of your answers, and you do the same here. First, answer the question below about how many minutes you spent on this chapter. Then click the button below that to gather every answer on this page into a single file and download it.
After clicking the “Download My Answers” button, this file will be saved in the Downloads folder on your computer. This action only downloads the file. It does not send the file to anyone. Unless your instructor tells you otherwise, send them this file as-is (for example, attached to an email or uploaded to your course’s learning management system).
Stopping, restarting and deleting the Codespace
A Codespace is your responsibility in the same way that your laptop is your responsibility. While a Codespace is running it counts against your free hours. An unused Codespace will be deleted by GitHub after 30 days.
There are three common ways to close a Codespace.
First, just leave it alone. GitHub will close it on its own after 30 minutes of inactivity, though we recommend changing that default to 15 minutes in your Codespaces settings.
Second, type Cmd/Ctrl + Shift + P. The Command Palette provides access to all VS Code commands. Type stop into the search bar.
On some browsers, the keyboard shortcut does not work. You can always access the Command Palette by clicking the search bar at the top of the window and typing > followed by key words from the command you would like to use.

Select “Codespaces: Stop Current Codespace.”
Third, you can go to your personal Codespaces control panel at https://github.com/codespaces. You can also reach this page from any page on GitHub by clicking the menu icon in the upper left and selecting “Codespaces”:

Which brings up this lst of options. Select “Codespaces.”

Your main Codespaces page should look something like this:

This shows all your Codespaces, both active and inactive. The ... menu on each row provides several commands, including “Stop Codespace.”

Simply closing the browser window does not stop your Codespace from running. Always stop a Codespace explicitly to preserve your free hours.
Now stop this Codespace using whichever method you prefer.
Once it is stopped, you can restart it from your Codespaces page by clicking the ... menu next to this Codespace and then selecting Open in Browser.

Once you are done with a Codespace, you should delete it. To do so, go to your Codespaces page, click the ... menu next to this Codespace and select Delete.
This Codespace was a sandbox. You do not own PPBDS/codespace-starter, so there is nowhere for your work to go once you stop using the Codespace. That is fine — you have already downloaded your answers, which is the only thing here worth keeping.
Delete your Codespace now. When you do, GitHub shows a message at the top of your Codespaces page confirming that it was deleted. Your screenshot should look similar to this.

Using your own machine
You can do all of this work on your own laptop, if you prefer. But, in that case, you are responsible for setting everything up. That means installing VS Code, Git and R. Ask your favorite AI to take a look at the .devcontainer/devcontainer.json file from PPBDS/codespace-starter. The AI will then give you good advice as to the steps to take.You may also find it useful to use the same VS settings which are defined there.
You will also need to install, by hand, various R packages. From the R Terminal, you would run commands like:
install.packages("pak")
You may be asked to select a CRAN mirror. It does not matter which you choose.
pak::pak("tidyverse")
pak::pak("PPBDS/vscode.tutorials")
These steps are not enough to perfectly replicate what we show in the Codespace. See PPBDS/devcontainers for more details. But this should be enough to get you started, should you decide to go this route.
Start a tutorial
This section shows you how to start a tutorial.
Create another Codespace, exactly as you did in the “Launching the Codespace” section above.
Once your Codespace is ready, look at the Activity Bar, the narrow vertical strip of icons on the far left. Hover over the icons until you find the one labeled R Tutorials, near the bottom, and click it. This lists the R packages that have tutorials. Click the package named vscode.tutorials to see its tutorials.
Find the tutorial named Orientation. Hover over its name and click the sideways triangle button that appears. Doing so starts the tutorial.

A new terminal named “R Tutorial” appears in the Panel.

The tutorial should automatically open in your browser.

Note how the web address includes cuddly-space-giggle, the GitHub name for my Codespace. The tutorial is running in the Codespace, viewable via my browser.
If the tutorial does not open automatically, hover over the web address in the “R Tutorial” terminal and press Ctrl + Click (Windows, Chromebook) or Cmd + Click (Mac).
You do not need to finish the Orientation tutorial now. After you finish, and download your answer, you should stop that Codespace and delete it.
Summary
You should have done the following:
- Signed up for a GitHub account.
- Downloaded your answers from these exercises.
- Started the Orientation tutorial from vscode.tutorials in a Codespace.
Let’s get started!
