Exercises

  1. Use the pipe operator to rewrite the following command in three ways:

    runif(10, min = 0, max = 5)
  2. Rewrite the following command using two pipe operators in succession:

    paste("hello", "there", "Bella")
    ## [1] "hello there Bella"
  3. Use the pipe operator and dplyr functions to rewrite the following command:

    head(subset(m111survey, sex == "female")[, c("height", "fastest")],6)

    The next few exercises are about the babynames data frame from the babynames package.

  4. Find the names for females born in 2015 that were given to more than 1% of female applicants (i.e., prop is bigger than 0.01).

  5. Use the pipe operator and dplyr functions to produce the following graph of the popularity of “Mary” and “Mia” as girl-names over the years. Note that popularity is given as number per one thousand applicants, i.e., as prop * 1000.