Description Usage Arguments Value Author(s) See Also Examples
sample
takes a sample of the specified size from the elements of
x
either with or without replacement. Unlike base::sample
,
sample
handles data frames in a reasonable manner.
1 |
x |
an integer, vector, or data frame. |
size |
a non-negative integer giving the number of items to choose. |
replace |
logical indicating whether sampling should be performed with or without replacement. |
prob |
a vector of probability weights for obtaining the elements of the vector being sampled. |
If x
is a vector, a vector of length size
with elements drawn from x
.
If x
is a integer, a vector of length size
with elements drawn from 1:x
.
If x
is a data frame, a data frame with size
rows, all the columns
in x
and one additional column indicating the location of the selected
rows in x
.
Randall Pruim (rpruim@calvin.edu)
1 2 | x <- data.frame(letter=letters[1:10], number=1:10)
sample(x,3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.