I would like to transform my database from a wide format to a long format so that I can make a plot where there are the years in the x axis and the shares in the y axis. I would like to draw a line for each family because the goal is to see the gap between the two 2034 values.
This is what my dataframe currently looks like:
And this is my desired output (I would call the x-axis "Year" and the y-axis "Share")
I have already tried using the "gather" option of "dplyr" using:
gather(CPS_fam.long, Year, Share, 2:5)
but I optain the years duplicated instead of the Family Name.
I cannot provide the data but any suggestion using a sample dataframe would be highly appreciated.