I have a column in my dataframe that is year of publication. The entries are numerous such as below:
df$year <- c(1989, 2014, 2014, 2014, 2013, 2010, 2006, 2006, 2006, 2006, 2016, 1995, 1995, 1995, 1995, 1995, 1995, 1995)
How do I categorise the data to be per decade, ie: 1960-1969 to be 1, 1970-1979 to be 2, etc up to 2010-2020
Thank you all.
One option is cut
cut(v1, breaks = seq(1960, 2020, by = 10),
labels = paste(seq(1960, 2010, by = 10), seq(1969, 2019, by = 10), sep="-"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.