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.
如何将一个向量分成两个,以便为每个新向量选择一个随机样本。但我总是想分成两半。例如
x <- 1:10 obj <- splitMyVector(x) obj$a > 5 3 9 7 10 obj$b > 8 4 1 6 2
注意:这样做的目的是做一个半可靠性。
split(sample(x),letters[seq(length(x))%%2+1]) $a [1] 9 7 10 4 2 $b [1] 6 1 8 3 5