Exercise

Soviet space dogs, the dog perspective

You'll be working on an pre-processed sample of the USSR space dogs database compiled by Duncan Geere and pre-loaded for you as space_dogs_df. Each of the 42 rows in this dataset represents a test rocket launch which had one or two very brave dogs on board.

Your goal is to reshape this dataset so that for each launch, each dog has a row.

The challenge is that in the column headers (name_1, name_2, gender_1, and gender_2), the part before the _ separator can point to two different variables (name and gender), while the second part always points to the dog ID (1st or 2nd dog).

Laika

Laika, the first animal to orbit Earth in 1957

Instructions

100 XP
  • As the first argument to pivot_longer(), pass the columns to pivot (name_1, name_2, gender_1, and gender_2).
  • Complete the names_to argument so that the first part of the column headers are reused.
  • Make sure NA values are dropped since not all rockets had two dogs.