类似于我在Using a sample list as a template for sampling from a large list without wraparound 的问题,我怎么知道这样做是否允许环绕?
因此,如果我有一个字母向量:
> all <- letters
> all
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
然后我从字母中定义一个参考样本,如下所示:
> refSample <- c("j","l","m","s")
其中元素之间的间距为 2(第 1 到第 2)、1(第 2 到第 3)和 6(第 3 到第 4),然后我如何从中选择n 个样本all
,其元素之间具有相同的环绕间距refSample
?例如"a","c","d","j"
,"q" "s" "t" "z"
和"r" "t" "u" "a"
将是有效样本,但"a","c","d","k"
不会。
同样,为函数参数化是最好的。