Plotara guide
Converting wide data to long format for plotting
What the difference is, why plotting and statistics tools want long format, and how to convert without writing pandas or tidyr code.
Almost every plotting and statistics tool wants long format. Almost every spreadsheet you collect is wide. This is the conversion step people lose an afternoon to.
The difference
Wide gives each measurement its own column. One row per subject:
| Subject | Week1 | Week2 | Week3 | |---|---|---|---| | 1 | 4.2 | 5.1 | 6.3 |
Long has one row per observation, with the variable name in its own column:
| Subject | Week | Value | |---|---|---| | 1 | Week1 | 4.2 | | 1 | Week2 | 5.1 | | 1 | Week3 | 6.3 |
Why tools want long
Grouping, colouring and faceting all work by pointing at a column. If your conditions are spread across separate columns, there is no single column to point at. Repeated-measures and mixed models need long format for the same reason: they need to know which observations belong to which subject.
What to watch for
Keep your identifier. Without a subject column, paired and repeated-measures analyses are impossible to run.
Column names become data. "Week1" becomes a value in the Week column, so name your columns as you want them to appear on the axis.
Numbers stored as text. After conversion, check the value column is numeric.
Doing it
In R this is pivot_longer, in Python pd.melt. In Plotara, wide format is detected on import and converted with one click, with the identifier column preserved.
Ready to put this into practice?
Try Plotara free for 30 daysNo credit card required. Windows and Mac.