sample_df: Random samples from data frames (corpora)

Description Usage Arguments Details Value Author(s)

Description

This function takes a random sample of rows from a data frame, in analogy to the built-in function sample (which sadly does not accept a data frame).

Usage

1

Arguments

df

a data frame to be sampled from

size

positive integer giving the number of rows to choose

replace

Should sampling be with replacement?

sort

Should rows in sample be sorted in original order?

prob

a vector of probability weights for obtaining the elements of the vector being sampled

Details

Internally, rows are selected with the function sample.int. See its manual page for details on the arguments (except for sort) and implementation.

Value

A data frame containing the sampled rows of df, either their original order (sort=TRUE) or shuffled randomly (sort=FALSE).

Author(s)

Stefan Evert


corpora documentation built on May 2, 2019, 4:56 p.m.

Related to sample_df in corpora...