Wide/Long Conversion

Last updated: January 18, 2021

The new pivot_wider() and pivot_longer() functions in tidyr are the best way to convert between wide and long data. Look at these slides for a good visual summary.


ℹī¸ This page is part of my knowledge base for R, the popular statistical programming language. I attempt to use idiomatic practices with the tidyverse collection of packages as much as possible. If you have suggestions for ways to improve this code, please contact me or use the survey link below..