sample_rows: Sample Random Rows from Data Frame

View source: R/sample_rows.R

sample_rowsR Documentation

Sample Random Rows from Data Frame

Description

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.

Usage

sample_rows(.data = NULL, n, .seed = 1, replace = FALSE)

Arguments

.data

an object; the source data.frame to be sampled from

n

a numeric value; sample size

.seed

(optional) a numeric value; the seed for randomly generating numbers.

replace

a logical value; should the sampling method use replacement? TRUE if yes, FALSE (by default) if no

Examples

iris_samp <- sample_rows(iris, 5, replace = FALSE)

mike-decarlo/caseling documentation built on March 17, 2023, 11:07 a.m.