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.
我需要一些帮助。如何创建以下向量序列:
1 1 1 1 2 2 2 3 3 4
我尝试使用 (rep) 和 (seq) 但仍然不成功。
尝试这个:
rep(1:4,4:1)
输出:
[1] 1 1 1 1 2 2 2 3 3 4
或更简洁:c(rep(1, 4), rep(2,3), rep(3, 2), 4)
c(rep(1, 4), rep(2,3), rep(3, 2), 4)
输出:[1] 1 1 1 1 2 2 2 3 3 4