Skip to content

Explain pivot_wider() alongside pivot_longer() in current Chapter 12 #43

Description

@mpjashby

Rationale

Current Chapter 12 explains the distinction between wide and long data and teaches pivot_longer(), but it does not teach the inverse operation, pivot_wider(). The downloadable report associated with current Chapter 14 uses pivot_wider(), while the full explanation currently appears only in current Chapter 15.

With current Chapter 12 moving before current Chapter 14, explaining both pivot directions together would make the data-shape discussion complete and remove a forward dependency from the report exercise.

Suggested change

  • Extend the long-and-wide-data section of 12_messy_data/index.qmd to introduce pivot_wider() immediately after pivot_longer().
  • Reuse the same small toy dataset so students can see one transformation reversed.
  • Explain names_from, values_from and, where useful, values_fill in plain language.
  • Emphasise that long data are usually convenient for analysis while wider forms can be useful for human-readable tables or analyses requiring separate variables.
  • Add a quiz question that asks students to choose between pivot_longer() and pivot_wider().
  • Revise current Chapter 15 so its first use of pivot_wider() refers back to current Chapter 12 rather than presenting the function as new.

Completion criteria

  • Students can distinguish the two pivot directions before reaching current Chapter 14.
  • The Chapter 14 report uses only arguments that have already been explained.
  • Current Chapter 15 reinforces rather than duplicates the initial explanation.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions