View source: R/text_searching.R
| sample.fragments | R Documentation |
Take a phrase, a labeling and a corpus and return text fragments containing that phrase.
Grab all phrases and then give sample of N from positive class and N from negative class. Sampling is to first sample from documents and then sample a random phrase from each of those documents.
sample.fragments(
phrases,
labeling,
corp,
N = 10,
char.before = 80,
char.after = char.before,
metainfo = NULL
)
phrases |
Phrases to examine (a list of strings) |
labeling |
– a vector of the same length as the corpus |
corp |
Corpus object (tm package Corpus object) |
N |
size of sample to make. |
char.before |
Number of characters of document to pull before phrase to give context. |
char.after |
As above, but trailing characters. Defaults to char.before value. |
metainfo |
– extra string to add to the printout for clarity if many such printouts are being generated. |
Other sample.fragments:
is.fragment.sample(),
print.fragment.sample()
library( tm )
data( bathtub )
sample.fragments( "bathtub", meta(bathtub)$meth.chl, bathtub )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.