I have a problem which seems quite simple but I have not been able to find a nice way of solving it.
If I have a vector of numbers, here representing years,
for example c(2000,2001,2002,2003, 2005, 2007,2008,2009,2010)
I would like it to return a string but not with all the numbers since it would be quite long but with intervals where it is possible so a string that would return “2000-2003, 2005, 2007-2010”
.
Does anyone have an easy way of doing this in general?