Description Usage Arguments Value See Also Examples
Sample randomly from a dfm object, from documents or features.
1 2 3 4 5 6 7 |
x |
the dfm object whose documents or features will be sampled |
size |
a positive number, the number of documents or features to select.
The default is the number of documents or the number of features, for
|
replace |
logical; should sampling be with replacement? |
prob |
a vector of probability weights for obtaining the elements of the vector being sampled. |
margin |
dimension (of a dfm) to sample: can be |
A dfm object with number of documents or features equal to size
, drawn
from the dfm x
.
sample
1 2 3 4 5 6 7 | set.seed(10)
dfmat <- dfm(c("a b c c d", "a a c c d d d"))
head(dfmat)
head(dfm_sample(dfmat))
head(dfm_sample(dfmat, replace = TRUE))
head(dfm_sample(dfmat, margin = "features"))
head(dfm_sample(dfmat, margin = "features", replace = TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.