Trying to find a way to mutate a new column into a dataframe that takes the 'year' column and rounds down to the first 0. The 'year' column is in dttm.
e.g. year = 1928, decade = 1920.
I've tried to mutate, trunc.Date, round.Date, and a few others.
I started by separating the dates:
df3 <- df2 %>% separate('Release Date', into=c("year","month","day"), sep = "-")
But i'm having trouble making a new column that has the corresponding decade next to each year.
df3 %>% mutate(year = round_date(year,"year",10))
I either get an out of bounds error, or an error that there aren't enough obs in the column.
Thanks for your help!
Zabada
-EDIT - the main reasons I want to do this is so that I can plot decades on the Y axis in ggplot and get a better graph.