category_highlight_tokens {tokenbrowser}R Documentation

Highlight tokens per category

Description

This is a convenience wrapper for tag_tokens() that can be used if tokens need to be colored per category

Usage

category_highlight_tokens(tokens, category, labels = NULL, alpha = 0.4,
  colors = NULL, span_adjacent = F)

Arguments

tokens

A character vector of tokens

category

A numeric vector with values representing category indices.

labels

A character vector with labels for the categories

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.

colors

A character vector with color names for unique values of the value argument. Has to be the same length as unique(na.omit(category))

span_adjacent

If TRUE, include adjacent tokens with identical attributes within the same tag

Value

a character vector of color-tagged tokens

Examples

tokens = c('token_1','token_2','token_3','token_4')
category = c(1,1,NA,2)
category_highlight_tokens(tokens, category)

[Package tokenbrowser version 0.1.0 Index]