Structure of data for panels models.

I want put the data base in long format.
It's my data:

But, i want put the years in rows and each code on columns keeping the id variable Countries. I need work with this structure for data panel models.
I tried with dcast function but only give me the last value of the year (2019).

I think the pivot_longer function in the tidyr package will help you. https://tidyr.tidyverse.org/reference/pivot_longer.html

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.