I'm new to R and started two weeks ago. I have a data set which i'm trying to convert into a panel data. See data set below
ID Empl93 Empl95 Sales93 Sales95 1 20 30 200 150 2 14 40 350 90 4 50 10 100 220 9 29 45 400 560 20 42 23 190 350
I need to convert this to a panel as below
ID Emply Sales Year 1 20 200 1993 1 30 150 1995 2 14 350 1993 2 40 90 1995 4 50 100 1993 4 10 220 1995 9 29 400 1993 9 45 560 1995
The rows are about 1600 and made up of random IDs, I can add the new column "Year" to the data frame. I have also been able to add the duplicate rows using the code below:
newdata <- newdata[rep(seq_len(nrow(newdata)), each=2),]
My problem is how to copy the Empl93, Empl95, Sales93, Sales95 values from first data frame and paste in the correspondent years in the panel. Thank you.