sample_rows | R Documentation |
It is common to want a random sampling of data from a large
data set for analysis of various forms. The sample_rows
function
takes arguments needed to return a random sample of a data frame.
Providing the source data frame, a sample size, and whether or not
replacement is allowed in the sampling is all that is required for
returning the sample. Row names (number typically) are returned in the
sample making it easy to identify which observations are selected into the
sample.
sample_rows(.data = NULL, n, .seed = 1, replace = FALSE)
.data |
an object; the source data.frame to be sampled from |
n |
a numeric value; sample size |
.seed |
|
replace |
a logical value; should the sampling method use replacement?
|
iris_samp <- sample_rows(iris, 5, replace = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.