# NOT RUN {
use("polmineR")
P <- partition("REUTERS", places = "argentina")
H <- html(P)
Y <- highlight(H, list(lightgreen = "higher"))
if (interactive()) htmltools::html_print(Y)
# highlight matches for a CQP query
H2 <- highlight(
H,
highlight = list(yellow = cpos(hits(P, query = '"prod.*"', cqp = TRUE)))
)
# the method can be used in pipe
if (require("magrittr")){
P %>% html() %>% highlight(list(lightgreen = "1986")) -> H
P %>% html() %>% highlight(list(lightgreen = c("1986", "higher"))) -> H
P %>% html() %>% highlight(list(lightgreen = 4020:4023)) -> H
}
# use highlight for kwic output
K <- kwic("REUTERS", query = "barrel")
K2 <- highlight(K, highlight = list(yellow = c("oil", "price")))
if (interactive()) K2
# use character vector for output, not list
K2 <- highlight(
K,
highlight = c(
green = "pric.",
red = "reduction",
red = "decrease",
orange = "dropped"),
regex = TRUE
)
if (interactive()) K2
# }
Run the code above in your browser using DataLab