## (1) From text string(s):
ts <- c("Hello world!", "This is a test to test this splendid function",
"Does this work?", "That's good.", "Please carry on.")
sum(nchar(ts))
# (a) simple use:
map_text_regex(ts)
# (b) matching patterns (regex):
map_text_regex(ts, lbl_hi = "\\b\\w{4}\\b", bg_hi = "[good|test]",
lbl_rotate = "[^aeiou]", angle_fg = c(-45, +45))
## (2) From user input:
# map_text_regex() # (enter text in Console)
## (3) From text file:
# cat("Hello world!", "This is a test file.",
# "Can you see this text?",
# "Good! Please carry on...",
# file = "test.txt", sep = "\n")
#
# map_text_regex(file = "test.txt") # default
# map_text_regex(file = "test.txt", lbl_hi = "[[:upper:]]", lbl_lo = "[[:punct:]]",
# col_lbl_hi = "red", col_lbl_lo = "blue")
#
# map_text_regex(file = "test.txt", lbl_hi = "[aeiou]", col_lbl_hi = "red",
# col_bg = "white", bg_hi = "see") # mark vowels and "see" (in bg)
# map_text_regex(file = "test.txt", bg_hi = "[aeiou]", col_bg_hi = "gold") # mark (bg of) vowels
#
# # Label options:
# map_text_regex(file = "test.txt", bg_hi = "see", lbl_tiles = FALSE)
# map_text_regex(file = "test.txt", angle_bg = c(-20, 20))
#
# unlink("test.txt") # clean up (by deleting file).
Run the code above in your browser using DataLab