colorscaled_browser {tokenbrowser} | R Documentation |
Convert tokens into full texts in an HTML file with color ramp highlighting
colorscaled_browser(tokens, value, alpha = 0.4, meta = NULL, col_range = c("red", "blue"), doc_col = "doc_id", token_col = "token", doc_nav = NULL, token_nav = NULL, filename = NULL, span_adjacent = T, ...)
tokens |
A data.frame with a column for document ids (doc_col) and a column for tokens (token_col) |
value |
A numeric vector with values between -1 and 1. Determines the color mixture of the scale colors specified in col_range |
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. |
meta |
A data.frame with a column for document_ids (doc_col). All other columns are added to the browser as document meta |
col_range |
The color used to highlight |
doc_col |
The name of the document id column |
token_col |
The name of the token column |
doc_nav |
The name of a column in meta, used to set a navigation tag |
token_nav |
Alternative to doc_nav, a column in the tokens, used to set a navigation tag |
filename |
Name of the output file. Default is temp file |
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()
## as an example, scale word colors based on number of characters scale = nchar(as.character(sotu_data$tokens$token)) scale[scale>6] = scale[scale>6] +20 scale = rescale_var(sqrt(scale), -1, 1) scale[abs(scale) < 0.5] = NA url = colorscaled_browser(sotu_data$tokens, value = scale, meta=sotu_data$meta) view_browser(url) ## view browser in the Viewer browseURL(url) ## view browser in default webbrowser