tokens_sample: Randomly sample documents from a tokens object

Description Usage Arguments Value See Also Examples

View source: R/tokens_sample.R

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

koheiw/quanteda.core documentation built on Sept. 21, 2020, 3:44 p.m.