Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的年份范围是 1981:1984。如何使用rep()函数得到如下结果: 对于每一轮rep,最近一年被丢弃:首先得到1981:1984,然后是1981:1983,然后是1981:1982,然后是1981,如表所示:
1981 1982 1983 1984 1981 1982 1983 1981 1982 1981
单程:
v = 1981:1984 v[ sequence(rev(seq_along(v))) ] # [1] 1981 1982 1983 1984 1981 1982 1983 1981 1982 1981