0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

R > sample() > 数値を取り出す > replace=True/False > リスト要素の再利用する/しない

Last updated at Posted at 2016-09-21
動作環境
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回以上取出せる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?