Week 3 Drill

Don’t Peek!

Here are the first letters of the names of several data verbs. (Repeated letters are for different verbs.) Complete the name and say briefly what the verb does.

Rather than looking at a list of verbs, do this just from memory.

  • A
  • G
  • J
  • M
  • F
  • S
  • S

Data verbs and their uses

Each of these tasks can be performed using a single data verb. For each task, say which verb it is:

Two steps

These questions refer to the diamonds data table. Take a look at the codebook (using help()) so that you’ll understand the meaning of the tasks.1

Each of the following tasks can be accomplished by a statement of the form

diamonds %>% 
  verb1( args1 ) %>% 
  verb2( args2 ) %>% 
  arrange( args3 ) %>% head( 1 )

Identify the verbs and arguments.

  1. Which color diamonds seem to be largest on average (in terms of carats)?
    • verb1:
    • verb2:
    • args1:
    • args2:
    • args3:
  2. Which clarity of diamonds has the largest average “table” per carat?
    • verb1:
    • verb2:
    • args1:
    • args2:
    • args3:
  3. What color of diamonds occurs the most frequently among diamonds with ideal cuts?
    • verb1:
    • verb2:
    • args1:
    • args2:
    • args3:
  4. What is the average price per carat of diamonds that cost more than $10000?
    • verb1:
    • verb2:
    • args1:
    • args2:
    • args3:
  5. Create a new data set that groups diamonds by color and displays the average depth and average table for each group.
    • verb1:
    • verb2:
    • args1:
    • args2:
    • args3:

Tables

Here is a small data table based on BabyNames. Take this table as the input.

name sex count year
Christina M 22 1967
Rotha F 7 1907
Wayman M 9 1997
Song F 11 1994
Julian M 535 1948
Vicky F 2945 1957
Kalia F 46 1989
Lissa F 102 1962
Brand M 10 1991
Josedejesus M 9 1985

Just by chance, this small sample pulled out the listing for Christina males.

Task

For each of the following outputs, identify the operation and write down the details of the operation.

  • Output Table 1
name sex count year
Rotha F 7 1907
Song F 11 1994
Kalia F 46 1989
Lissa F 102 1962
Vicky F 2945 1957
Wayman M 9 1997
Josedejesus M 9 1985
Brand M 10 1991
Christina M 22 1967
Julian M 535 1948
  • Output Table 2
name sex count year
Rotha F 7 1907
Song F 11 1994
Vicky F 2945 1957
Kalia F 46 1989
Lissa F 102 1962
  • Output Table 3
name sex count year
Christina M 22 1967
Julian M 535 1948
  • Output Table 4
total
3696
  • Output Table 5
name count
Christina 22
Rotha 7
Wayman 9
Song 11
Julian 535
Vicky 2945
Kalia 46
Lissa 102
Brand 10
Josedejesus 9

Changing Cases

There’s only one data verb that takes a single data table as input and produce an output that (in general) has a different meaning to the case. Which one?

There’s only one data verb that takes two data tables as input rather than just a single data table. Which one?

Please use the comment system to make suggestions, point out errors, or to discuss the topic.

comments powered by Disqus


  1. Motivated by this problem set based on drills by Garrett Grolemund which are licensed under the CC Attribution-Noncommercial-Share Alike 3.0 License.