Adds html tags to create a highlighted testimony corresponding to word frequency.
To render correctly, the object produced from highlighted_text() can be added outside of a code chunk in an .Rmd document in the `r highlighted_text()` format.
Alternatively, the html output can be saved by using the xml2 package as follows:
xml2::write_html(xml2::read_html(highlighted_text(), "filepath.html"))
Usage
highlighted_text(plot_object, labels = c("", ""))Arguments
- plot_object
plot object resulting from
collocation_plot()- labels
lower and upper labels for the gradient scale
Examples
# Tokenize the derivative document
toks_comment <- tokenize_derivative(comment_example, text_column = "Notes")
# Tokenize source document
toks_source <- tokenize_source(transcript_example)
# Compute collocation frequencies
collocation_object <- collocate_comments(toks_source, toks_comment)
# Merge frequencies with source document to provide averages by word and correct formatting
merged_frequency <- transcript_frequency(transcript_example, collocation_object)
# Create a plot object to assign colors based on frequency
freq_plot <- collocation_plot(merged_frequency)
# Add html tags to create a highlighted version of the source document
page_highlight <- highlighted_text(freq_plot, merged_frequency)
