I have a dataset like this:
structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), year1 = c(2022,
2020, 2023, 2022, 2020, 2023, 2022, 2020, 2023, 2022), year2 = c(2023,
2022, 2024, 2023, 2022, 2024, 2023, 2022, 2024, 2023)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))
For each ID, there are two years ("year1" and "year2"). I want to change the structure of the dataset so it looks like this:
Can somebody help me? Thank you