Description Usage Arguments Value Examples
Convert tokens into full texts in an HTML file with category highlighting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
tokens |
A data.frame with a column for document ids (doc_col) and a column for tokens (token_col) |
category |
Either a numeric vector with values representing categories, or a factor vector, in which case the values are used as labels. If a numeric vector is used, the labels can also be specified in the labels argument |
alpha |
Optionally, the alpha (transparency) can be specified, with 0 being fully transparent and 1 being fully colored. This can be a vector to specify a different alpha for each value. |
labels |
A character vector giving names to the unique category values. If category is a factor vector, the factor levels are used. |
meta |
A data.frame with a column for document_ids (doc_col). All other columns are added to the browser as document meta. |
colors |
A character vector with color names for unique values of the category argument. Has to be the same length as unique(na.omit(category)) |
doc_col |
The name of the document id column |
token_col |
The name of the token column |
filename |
Name of the output file. Default is temp file |
unfold |
Either a character vector or a named list of vectors of the same length as tokens. If given, all tokens with a tag can be clicked on to unfold the given text. If a list of vectors is given, the values of the columns are concatenated with the column name. E.g. list(doc_id = 1, sentence = 1) will be [doc_id = 1, sentence = 2]. |
span_adjacent |
If TRUE, include adjacent tokens with identical attributes within the same tag |
... |
Additional formatting arguments passed to create_browser() |
The name of the file where the browser is saved. Can be opened conveniently from within R using browseUrl()
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## as an example, use simple grep to code tokens
code = rep(NA, nrow(sotu_data$tokens))
code[grep('war', sotu_data$tokens$token)] = 'War'
code[grep('mother|father|child', sotu_data$tokens$token)] = 'Family'
code = as.factor(code)
url = categorical_browser(sotu_data$tokens, category=code, meta=sotu_data$meta)
view_browser(url) ## view browser in the Viewer
if (interactive()) {
browseURL(url) ## view in default webbrowser
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.