Data Reshaping
library(reshape2)
prod.wage.melt <- melt(prod.wage, id.vars = "Year", measure.variables = c("Hourly_compensation", "Net_productivity"), variable.name = "Prod.or.Compensation", value.name = "Cumulative.Changes")
prod.wage.2.melt <- melt(prod.wage.2, id.vars = "Year", measure.variables = c("Real_median_hourly_compensation", "Real_average_hourly_compensation", "Net_productivity"), variable.name = "Prod.or.Compensation", value.name = "Cumulative.Changes")
str(prod.wage.melt)
## 'data.frame': 134 obs. of 3 variables:
## $ Year : int 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 ...
## $ Prod.or.Compensation: Factor w/ 2 levels "Hourly_compensation",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Cumulative.Changes : num 0 6.3 10.5 11.8 15 20.8 23.5 28.7 33.9 37.1 ...
str(prod.wage.2.melt)
## 'data.frame': 126 obs. of 3 variables:
## $ Year : int 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 ...
## $ Prod.or.Compensation: Factor w/ 3 levels "Real_median_hourly_compensation",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Cumulative.Changes : num 0 -2 -0.5 0.4 1.3 2.5 1.9 1.1 -1.2 0.5 ...