Below is the sample data. Pct10,pct25,median,and pct75 are hourly wages. Their counterparts below are annual salaries. The quandary is how to basically fold only these below while duplicating the descriptive items; industry and occupation. The desired result is below. Ratetype would be a new field/column with 1 representing hourly and 4 being annual. My previous attempts have resulted in far too many rows being created. In this case, it would 4 original * 2 for an end result of 8.
First, is melt the best way to go about this?
Second, is it as simple as occmelt2<- melt(occmelt, id.vars = c()) and simply specifying the correct Id variables
industry<-c(000000,000000,000000,000000)
occupation<-c(110000,120000,130000,140000)
pct10 <-c(11,15,26.25,19.50)
pct25 <-c(13,14.50,15.65,15.95)
median <-c(22,22.50,23.50,29)
pct75<-c(24,23.75,22,26.50)
Annualpct10 <-c(44000,45000,46000,49000)
Annualpct25 <-c(48000,49000,52000,54000)
Annualmedian <-c(54000,55000,56700,59800)
Annualpct75 <-c(64000,65000,71000,72700)
occmelt <- data.frame(industry,occupation,pct10,pct25,median,pct75,Annualpct10,Annualpct25,Annualmedian,Annualpct75)
industry occupation rateype pct10 pct25 median pct75
000000 110000 1 11 13 22 24
000000 110000 4 44000 48000 54000 54000
000000 120000 1 15 14.50 22.5 23.75
000000 120000 4 45000 49000 55000 65000