I have a wide form dataframe
structure(list(Id = structure(2:1, .Label = c("Jake", "Jim"
), class = "factor"), Q2.2 = c(NA, NA), Q2.4 = c(NA, NA), Q2.5 = c(NA,
NA), Q2.6 = c(NA, 4L), Q3.2 = c(NA, NA), Q3.4 = c(NA, NA), Q3.5 = c(NA,
NA), Q3.6 = c(4L, NA), Q4.2 = c(NA, NA), Q4.4 = c(2L, NA), Q4.5 = c(NA,
3L), Q4.6 = c(4L, NA), Q5.2 = c(NA, NA), Q5.4 = c(2L, NA), Q5.5 = c(NA,
NA), Q5.6 = c(NA, NA)), class = "data.frame", row.names = c(NA,
-2L))
I'm trying to turn this into a long form dataframe based only on the number after the period. So all the values in columns with a .2
should go in one column and all values in columns with a .4
should go in another column. This goes on for each of the suffixes. To explain more clearly, I want something that looks like this