I have a year range 1981:1984. How can use rep() function to get the following results: For each round rep, the latest year is dropped off: first get 1981:1984, then 1981:1983, then 1981:1982, then 1981 as shown in the table:
1981
1982
1983
1984
1981
1982
1983
1981
1982
1981
rep
for this task?unlist(sapply(1:4, function(i){1981:(1985-i)}))
would do the trick. – Jealie