Hi I have imputed my data in wide format and I would like to convert my imputed data to long format.
This is my data
I am using this code to convert my imputed data to long format
imp_comp <-complete(imp1, action="long", include = TRUE) %>%
pivot_longer( cols = 3:16,
names_to = c(".value", "wave"),
names_pattern = "(.)_(.)")
The problems is that funnily R is trying to combine columns 10-14 (veg24_1, veg24_2, fruit24_1, fruit24_2) in one column named 4 instead of 2 columns (veg24, fruit24)
How can I assign columns 10-14 to 2 columns? Thanks in advance.