2 Vectors and Tibbles

Today, we’ll learn about data structures in R using a short set of “koans”: fill-in-the-blank exercises designed to teach programming concepts through discovery rather than direct instruction. The idea comes from zen koans, which are paradoxical questions or stories to provoke insight. Programming koans borrow that spirit: instead of explaining everything up front, they let you figure things out by completing a small piece of code.

Notes on Vectors, Tibbles, and Pipes

Download this assignment

Go here: https://github.com/cobriant/tidyverse-koans-part1

Click on the green button that says Code and then hit Download ZIP.

Find the file (probably in your downloads folder). On Macs, opening the file will unzip it. On Windows, you’ll right-click and hit “extract”. Then navigate to the new folder named tidyverse_koans-part1-main and double click on the R project tidyversekoans.Rproj. RStudio should open. If it doesn’t, open RStudio and go to File > Open Project and then find tidyversekoans.Rproj.

In RStudio, go to the lower right hand panel and hit the folder R. This takes you to a set of 3 exercises (koans) you’ll complete during class today.

Open the first koan: K01_vector.R. Before you start, modify 2 keybindings:

First, make it so that you can hit Cmd/Ctrl Shift K to compile a notebook:

Macs: Tools > Modify keyboard shortcuts > filter for Compile Notebook > Cmd Shift K > Apply

Windows: Tools > Modify keyboard shortcuts > filter for Compile Notebook > Ctrl Shift K > Apply

Second, make it so that you can hit Cmd/Ctrl Shift T to run the test for the active koan:

Macs: Tools > Modify keyboard shortcuts > Run a test file > Cmd Shift T > Apply

Windows: Tools > Modify keyboard shortcuts > Run a test file > Ctrl Shift T > Apply

Now hit Cmd/Ctrl Shift T (Cmd Shift T on a mac; Ctrl Shift T on windows). You’ve just tested the first koan. You should see:

[ FAIL 0 | WARN 0 | SKIP 10 | PASS 0 ]

What does this mean? If there are errors in your R script, the test will not complete. Since it completed, you know there are no errors. Since FAIL is 0, you also haven’t failed any of the questions yet. But PASS is also 0, so you haven’t passed the questions either. Since they’re blank right now, the test will skip them. That’s why SKIP is 10.

Go ahead and start working on the koans and learning about the tidyverse!

When you’re finished with a koan, make sure to run the tests one last time (Ctrl/Cmd Shift T) and then publish an html version of the document (Ctrl/Cmd Shift K).

Submit on Canvas (one copy per group)

Upload your 3 html files (K01, K02, and K03) to Canvas.