6.7 Extra Practice

Keep practicing these functions! The more you practice, the better you’ll be when it comes time to manage your own code!

Using the diamonds built-in dataset (requires tidyverse), perform the following tasks:

  1. View all of the variable names in diamonds (hint: View()).

  2. Arrange the diamonds by:

  • Lowest to highest price (hint: arrange())

  • Highest to lowest price (hint: arrange(), desc())

  • Lowest price and cut

  • highest price and cut

  1. Arrange the diamonds by lowest to highest price and worst to best clarity.

  2. Create a new variable named salePrice to reflect a discount of $250 off of the original cost of each diamond (hint: mutate()).

  3. Remove the x, y, and z variables from the diamonds dataset (hint: select()).

  4. Determine the number of diamonds there are for each cut value (hint: group_by(), summarize()).

  5. Create a new column named totalNum that calculates the total number of diamonds.