There’s some explanation on what reshaping data in R means, why we do it, as well as the history, e.g., melt() vs gather() vs pivot_longer() in a previous post: New intuitive ways for reshaping data in R That post shows how to reshape a single variable that had been recorded/entered across multiple different columns. But if multiple different variables are recorded over multiple different columns, then this is what you might want to do:

Continue reading

TLDR: there are two new and very intuitive R functions for reshaping data: see Examples of pivot_longer() and pivot_wider() below. At the time of writing, these new functions are extremely fresh and only exist in the development version on GitHub (see Installation), we should probably wait for the tidyverse team to officially release them (in CRAN) before putting them into day-to-day use. Exciting! Introduction The juxtapose of data collection vs data analysis: data that was very easy to collect, is probably very hard to analyse, and vice versa.

Continue reading

Author's picture

Riinu Pius (Ots)

if it aint broke, you’re outdated

Senior Data Manager

Edinburgh, UK