I have some df cells that contain lists of years. Most are years typed out and separated by commas: "1990, 1992, 2001", but some use colon operators: "1990:2000". Even some use a combination: "1990, 1995:1999, 2001"
Is there a way in R to convert these different kinds of strings into consistent comma separated values still within one cell in r?
test2 <- data.frame(series = c(1,2,3),
years = c("1990, 1992, 2001", "1990:2000","1990, 1995:1999, 2001"))
# Desired output:
series years
1 1 1990, 1992, 2001
2 2 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
3 3 1990, 1995, 1996, 1997, 1998, 1999, 2001