My Data Frame looks like this (only first 6 columns visible):
There is one "Year" Column and for every Country two values which have a prefix "R_" and "Ineq_" respectively. For clarification: Every country has two values with the names "R_'Country Name'" and "Infl_'Country Name'".
I want to reshape my Data frame for a Panel regression like this:
Country Year R Infl
Canada 1971 x1 x2
Canada 1972 x1 x2
Canada 1973 x1 x2
...
Columbia 1971 x1 x2
Columbia 1972 x1 x2
Columbia 1973 x1 x2
...
USA 1971 x1 x2
...
How can I do it? I found this post Data Transformation in R for Panel Regression but it did not help me.
I would appreciate any help, thanks!