Floor a year to the decade in R
I would like to floor a set of dates to the nearest decade, e.g: 1922 --> 1920, 2099 --> 2090, etc. I was hoping I could do this in Lubridate, as in: floor_date(1922, 'decade') But I get: Error in match.arg(unit) : 'arg' should be one of “second”, “minute”, “hour”, “day”, “week”, “month”, “year” Is there any way to do this gracefully, perhaps avoiding a bunch of if-else statement to do the binning, and hopefully avoiding a bunch of cut s to do the grouping? Floor a Year in R to nearest decade: Think of Modulus as a way to extract the rightmost digit and use it to subtract from the original