Based on the data and code below how can I split the below df
by year and name the subsequent dfs
MR_2022
and so on?
Code:
# Sample data
df = structure(list(id = c(1, 1, 1, 1, 2, 2, 2, 2, 35555, 35555, 35555
), year = c(2022, 2022, 2021, 2021, 2020, 2020, 2019, 2019, 2018,
2022, 2022)), class = "data.frame", row.names = c(NA, -11L))
# Split df by year
df %>% subset() #?....