Pivots Part 2

Making longer data

Now that you have mastered, pivoting wider, can you go back the other way?

Starting with our first widened table, which will be in a tibble called gender_table.

can you convert the data back to its original form, to this?

Warning

Part of pivot_longer() requires you to specify which columns will be pivoted to rows, but this can be specified in any number of ways. Our droid code checker is not as smart as you are, though, so you need to specify those in a very specific way.

Set the value to: feminine:masculine

Use what you’ve learned young padawan!

Solution
gender_table |> pivot_longer( cols = feminine:masculine, names_to = "gender", values_to = "n" )
gender_table |> 
  pivot_longer(
    cols = feminine:masculine,
    names_to = "gender",
    values_to = "n"
  )
Hint

Note the warning above that you have to specify the cols = argument in a very specific way.

Beyond that, perhaps check the pivot_longer() arguments of the pivot vignette.

You’re done with this Trial

Darth Vader would tremble in your presence! Please inform your JedR Master that you have completed this trial. You are free to attempt the next JedR Trial or continue with JedR Training.