R4DS Week 1: Don’t Panic!

Jesse Maegan
4 min readSep 6, 2017

--

It’s Wednesday, and we’re getting ready to close out week 1 of our “R for Data Science” online learning community, with week 2 starting on Friday. The objectives for this week were to read through and complete the associated practice exercises in the following sections:

  • Welcome
  • Section 1, Introduction: no practice problems
  • Section 4, Workflow: basics: Practice questions 1–3
  • Section 6, Workflow: scripts: Practice questions 1 & 2
  • Section 8, Workflow: projects: no practice problems

If you haven’t started yet, and you’re a bit worried about what you should know and be able to do, we’ve got you covered! What follows is a step-by-step explanation of what you need to do to catch up in the least amount of time. It glosses over quite a bit, but it will get you up and running within about 20 minutes. From there you can go back through the readings for the week and review any content areas that are still unclear.

Do this:

  1. Install R
  2. Install RStudio

Did something go wrong? Tell us about it in the week 01 Slack channel and we’ll help you get it sorted!

  1. Open RStudio
  2. Within RStudio, go to File > New Project > New Directory > Empty Project
  3. Under “Directory name: ” type r4ds
  4. Look at what shows up in the white box under “Create project as a subdirectory of: ” — this is where the Project and all of its files will live. Store it in a place you feel comfortable accessing on a regular basis. There are best practices around this, but for now we’re just looking to get started.
  5. Make sure that the two white checkboxes immediately underneath the directory location are unchecked. You do not need to create a git repository, nor do you need to use packrat at this point in time.
  6. Do make sure the checkbox in “Open in new session” is checked.
  7. Click “Create Project.”
  8. If you see three “boxes” within RStudio instead of four, go to File > New File > R script. You’re going to type a lot of your code into files (R scripts) within this box (the Editor). One way to think of it is that R scripts (the files you save code to) show up in the Editor window. Other types of files can live in the Editor too — but we don’t need to worry about them right now.
  9. The box on the bottom left is your console. This is a great place to mess around with code and see what you can do. This is a very bad place to let code live permanently! If you do something in the console that works and you need to use, write it in the R script in your Editor window.
  10. In your console type (don’t cut and paste — the typing is good practice!) the following, then hit Enter:
install.packages("tidyverse")

Did something go wrong? Tell us about it in the week 01 Slack channel and we’ll help you get it sorted!

Read (and do) these:

Read Section 4.1: Coding basics, and enter the example code provided into your new R script (the file in the Editor box on the top left). You have four options for running the code:

  1. Press “Run” in the menu bar on the top of your R Script — this will run everything in your R script
  2. Use Cmd/Ctrl + Shift + S, which will also run everything in your R script (this does other things, too — you can read about that here).
  3. Use Cmd/Ctrl + Alt + R, which will also run everything in your R script.
  4. Put your cursor on the very first line (line 1!) in your R script. Now hit Cmd/Ctrl + Enter. What happens? Do it again. Now what happens? Repeat until the cursor has moved past the code you’ve written.

Read Section 8.5: Summary. Take 10 minutes or so to look up any vocabulary words or concepts in the summary that aren’t clear. If they’re still not clear after spending time looking them up, ask for clarification in the week 01 Slack channel!

Tell us how week 01 is going for you in our week 01 Slack channel!

--

--

Jesse Maegan

molecular biologist turned public school teacher before falling in ❤️ with non-profit data science. perpetual #rstats noob.