I have a column with a series of ID's that I need to recode into something that's a bit more intuitive. This is an example of my file:
ID = c("DR-0001", "DR-0002", "DR-0003", "DR-0004", "DR-0001", "DR-0002", "DR-0001")
df <- data.frame(ID)
where I want to create a new column where I relabel entries. In pseudo code I want the following:
df$ID_useful = 2019/01 if df$ID == "DR-0001", 2015/06 if df$ID == "DR-0002" etc.
so that the end result would be something like this:
ID = c("DR-0001", "DR-0002", "DR-0003", "DR-0004", "DR-0001", "DR-0002", "DR-0001")
ID_useful = c("2019/01", "2015/06", "1995/02", "2012/08", "2019/01", "2015/06", "2019/01")
And I'm not sure how to do this without creating a billion ifelse command lines. Any advice is appreciated!