Useful R functions

Random Samples and Permutations

sample(x, size, replace = FALSE, prob = NULL) 
sample.int(n, size = n, replace = FALSE, prob = NULL)

 

Samples in Normal Distribution

rnorm(n, mean = 0, sd = 1)

 

Generate Factor Levels

gl(n, k, length = n*k, labels = seq_len(n), ordered = FALSE)

 

Generate Repeated Numbers

rep(0:1, each = 5)
[1] 0 0 0 0 0 1 1 1 1 1

 

posted @ 2015-01-25 07:51  jimbo  阅读(230)  评论(0编辑  收藏  举报