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.
我想知道是否有更简单的方法来制作列表,例如 10 '4'、20 '6' 和 30 '3',然后example <- c(4,4,4,4,...)使用函数 'rep' 手动编写 ( )。我知道我可以重复某个序列 n 次,也可以重复 n 次,但我不知道如何用不同数量的每个数字制作一个。
example <- c(4,4,4,4,...)
只需将rep两个参数都用作所需的向量:
rep
x <- rep(c(4, 6, 3), c(10, 20, 30)) table(x) 3 4 6 30 10 20