有时候,一个"?sample" 比到论坛上找解释还要快:
Random Samples and Permutations
Description
sample takes a sample of the specified size from the elements of x using either with or without replacement.
Usage
sample(x, size, replace = FALSE, prob = NULL)
sample.int(n, size = n, replace = FALSE, prob = NULL)
Arguments
x
Either a vector of one or more elements from which to choose, or a positive integer. See ‘Details.’
n
a positive number, the number of items to choose from. See ‘Details.’
size
a non-negative integer giving the number of items to choose.
replace
Should sampling be with replacement?
prob
A vector of probability weights for obtaining the elements of the vector being sampled.
|