0

I've trying to unsucessfully do this in R:

I have data in the format:

Code 2004 2005
120005 4 2
120010 0 1

And I want to convert the data to this:

Code Year Value
120005 2004 4
120005 2005 2
120010 2004 0
120010 2005 1

How would you do it?

Phil
  • 5,491
  • 3
  • 26
  • 61
  • Try with `tidyr::pivot_longer(data, -Code, names_to = "Year", values_to = "Value")`. See https://stackoverflow.com/questions/5890584/how-to-reshape-data-from-long-to-wide-format. – stefan Nov 27 '21 at 23:59
  • Worked perfectly! Many thanks! – Richter Nov 28 '21 at 00:02

0 Answers0