Chapter 1

How to use R

We need to go over some basics before we get to the fun part of playing with data in R.

Like all programming languages, R is very particular about syntax and data structures.

It will help in the long run if you know how functions work, how to work around quirks in R, and strategies on what to do when you inevitably run into an error or get stuck. We’ll also walk through some basic data exploration and validation.

These are the sections you’ll be going over in this chapter:

Files and folders

We won’t need to download files for this chapter since everything can by typed (or copy and pasted) into the console or into a script.

However, the repo for this class is on Github if you’d like to follow along that way. It can be easily downloaded to your desktop with the following commands:



Test yourself

There are links to exercise what you’ve learned spread through out this section.

It’s possible to run these files locally to test yourself if you’ve downloaded the files for the chapter as instructed above.

Make sure your project directory is correct and then run these lines in the console:


and then


© Copyright 2018, Andrew Ba Tran

© Copyright 2018, Andrew Tran