Useful R functions

Random Samples and Permutationsdom

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

 

Samples in Normal Distributionspa

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

 

Generate Factor Levelscode

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

 

Generate Repeated Numbersorm

rep(0:1, each = 5)
[1] 0 0 0 0 0 1 1 1 1 1
相關文章
相關標籤/搜索