Below is the sample data and my first attempt at doing this. The desired result is at the bottom. No errors but not yielding the desired result. My primary question is this... to get the desired result, what should i put in the "cols" section?
periodyear3 <-c(2020,2020,2020,2020,2020,2020,2020,2020,2020,2020,2020,2020)
month3<-c(1,2,3,4,5,6,1,2,3,4,5,6)
indcode3<-c(624410,624410,624410,624410,624410,624410,72,72,72,72,72,72)
employment3 <-c(25,25,26,27,28,29,85,86,87,88,89,90)
wages3 <-c(10000,10001,10002,10003,10004,10005,12510,12515,12520,12520,16528,19874)
pivotexample <- data.frame(periodyear3,month3,indcode3,employment3,wages3)
indcomp <- pivotexample %>%
dplyr::select("indcode3","periodyear3","month3","employment3") %>%
dplyr::ungroup() %>%
tidyr::pivot_longer(cols = periodyear3:employment3, names_to = "indcode", values_to ="employment")
periodyear3 month3 624410 72
2020 1 25 85
2020 2 25 86
2020 3 26 87
2020 4 27 88
2020 5 28 89
2020 6 29 90