## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## -----------------------------------------------------------------------------

# load the library
library(highlightr)
library(knitr)

# View first 6 observations
knitr::kable(head(notepad_example))


## -----------------------------------------------------------------------------

study_transcript <- notepad_example[notepad_example$ID == "source",]$Text

knitr::kable(study_transcript)


## -----------------------------------------------------------------------------

# connect collocation frequencies to source document

merged_frequency <- collocation_frequency(notepad_example, source_row=which(notepad_example$ID=="source"), text_column = "Text", fuzzy=TRUE)


## -----------------------------------------------------------------------------

# connect collocation frequencies to source document

merged_frequency <- collocation_frequency(notepad_example, source_row=which(notepad_example$ID=="source"), text_column = "Text", fuzzy=TRUE, n_bands=100)

knitr::kable(head(merged_frequency), digits=2)

## -----------------------------------------------------------------------------

# create `ggplot` object of the transcript

freq_plot <- collocation_plot(merged_frequency)

## -----------------------------------------------------------------------------

# add html tags to source document

page_highlight <- highlighted_text(freq_plot)


## ----eval=FALSE---------------------------------------------------------------
# 
# # load `xml2` library
# 
# library(xml2)
# 
# # save html output to desired location
# 
# xml2::write_html(xml2::read_html(page_highlight), "filename.html")
# 

## -----------------------------------------------------------------------------

# connect collocation frequencies to source document

merged_frequency_nonfuzzy <- collocation_frequency(notepad_example, source_row=which(notepad_example$ID=="source"), text_column = "Text")

# create a `ggplot` object of the transcript, and change colors of the gradient

freq_plot_nonfuzzy <- collocation_plot(merged_frequency_nonfuzzy, colors=c("#15bf7e", "#fcc7ed"))

# add html tags to source document

page_highlight_nonfuzzy <- highlighted_text(freq_plot_nonfuzzy)

## -----------------------------------------------------------------------------

# connect collocation frequencies to source document

merged_frequency_2col <- collocation_frequency(notepad_example, source_row=which(notepad_example$ID=="source"), text_column = "Text", collocate_length = 2)

# create a `ggplot` object of the transcript

freq_plot_2col <- collocation_plot(merged_frequency_2col)

# add html tags to source document

page_highlight_2col <- highlighted_text(freq_plot_2col)

