Description Usage Arguments Value See Also Examples
View source: R/tokens_sample.R
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).
1 | tokens_sample(x, size = ndoc(x), replace = FALSE, prob = NULL)
|
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. |
A tokens object with number of documents or features equal to
size
, drawn from the tokens x
.
sample
1 2 3 4 5 | set.seed(10)
toks <- tokens(data_corpus_inaugural[1:10])
head(toks)
head(tokens_sample(toks))
head(tokens_sample(toks, replace = TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.