从给定的矩阵元素创建折叠

Create folds from given elements of matrix

我有一个特定数字的数值向量:

str(vector)
 int [1:15463] 389 1732 1737 2127 2205 3163 5166 5601 5981 6860 ...

我想创建 n 个包含上述数字的折叠。

当我尝试使用 caret

中的函数 createFolds
flds <- createFolds(vector,10)

我只得到 1 到 length(vector) 范围内的数字。

如何创建仅包含该向量值的折叠?

试试这个:

lapply(flds, function(x) vector[x])