我想用一个简单的一行命令随机重新组织向量中数字的顺序?
我的特定向量 V 对于从 1 到 10 的每个值都有 150 个条目:
V <- rep(1:10, each=150)
最佳答案
是的。
sample(V)
来自?样本
:
For ‘sample’ the default for ‘size’ is the number of items inferred from the first argument, so that ‘sample(x)’ generates a random permutation of the elements of ‘x’ (or ‘1:x’).
关于r - 如何随机化向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13765972/