sample_rows: Sample Random Rows from Data Frame

Description Usage Arguments Examples

View source: R/sample_rows.R

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

1
sample_rows(x = NULL, n, seed = 1, replace = FALSE)

Arguments

x

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 repalcement? TRUE if yes, FALSE (by default) if no

Examples

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

mike-decarlo/caser documentation built on Sept. 23, 2019, 7:15 a.m.