Mutating columns

Author

Jeffrey R. Stevens

Published

February 15, 2023

For these exercises, we’ll use the dog breed traits data set, so import that from https://jeffreyrstevens.quarto.pub/dpavir/data/dog_breed_traits.csv (if you don’t already have it) and assign it to traits.

# >
  1. View traits to see what it looks like.
# >
  1. Reassign traits with only the columns Breed through Coat Length.
# >
  1. Reassign traits removing the Drooling Level column. That’s gross.
# >
  1. What terrible column names! Reassign traits and change the column names to "breed", "affectionate", "children", "other_dogs", "shedding", "grooming", "coat_type", "coat_length". Note, use the colnames() function rather than select() or rename() since you already have the full vector of names.
# >
  1. The ratings are supposed to run from 0 to 4 rather than 1 to 5. Change the affectionate column by subtracting 1 from the original numbers to rescale the values. Don’t reassign traits.
# >
  1. Actually, all of the ratings need to be rescaled. Subtract 1 from all of the ratings columns by using across().
# >
  1. Create a new column called coat that combines the coat_type and coat_length columns by pasting the values of those two columns separated by -.
# >
  1. Create a new column called shed that dichotomizes shedding such that values of 3 and above are “A lot” and values below 3 are “Not much”. Do you need to account for missing data?
# >
  1. Use rowwise() to calculate the mean rating for the children and other_dogs columns in a column called mean_rating.
# >
  1. Create a column called coat_type2 that categorizes the coat_type values in the following way and puts it after coat_type:
# >