Pivoting data

Author

Jeffrey R. Stevens

Published

February 24, 2023

For these exercises, we’ll use a new clean version of the dog breed traits data set.

  1. Import data from https://jeffreyrstevens.quarto.pub/dpavir/data/dog_breed_traits_clean.csv and assign to traits.
# >
  1. Create traits2 where we delete the coat columns, so we only have breed and ratings data.
# >
  1. Is traits2 tidy?

  2. Is traits2 in wide or long format?

  3. Reshape traits2 so that all of the ratings scores are in a single column called rating with a column labeling what kind of rating it is called scale. Assign this to traits3.

# >
  1. How would we check if traits3 has the expected number of rows?

  2. Create traits4 by removing the rows with affectionate, children, and other_dogs as values of scale.

# >
  1. Spread out the data into wide format with separate columns for the shedding and grooming data, then create a new column diff that subtracts grooming from shedding ratings.
# >