動作環境
RStudio 0.99.903 on Windows 7 pro
R version 3.3.1
sample()を使って値を取り出す。
> x<-1:5
> sample(x,10,rep=FALSE)
Error in sample.int(length(x), size, replace, prob) :
cannot take a sample larger than the population when 'replace = FALSE'
> sample(x,10,rep=TRUE)
[1] 1 3 3 1 1 1 5 2 5 1
rep=FALSEだと5個のリストは5回しか取出せない。
rep=TRUEの場合はリスト要素を再利用するので6回以上取出せる。