tokens_sample: Randomly sample documents from a tokens object

Description Usage Arguments Value See Also Examples

Description

Sample tokenized documents randomly from a tokens object, with or without replacement. Works just as sample works, for document-level units (and their associated document-level variables).

Usage

1
tokens_sample(x, size = ndoc(x), replace = FALSE, prob = NULL)

Arguments

x

the tokens object whose documents will be sampled

size

a positive number, the number of documents or features to select

replace

logical; should sampling be with replacement?

prob

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

Value

A tokens object with number of documents or features equal to size, drawn from the tokens x.

See Also

sample

Examples

1
2
3
4
5

quanteda/quanteda documentation built on June 15, 2019, 8:36 a.m.