# (0) Prepare:
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))
# (1) From character map:
# (a) simple:
cm_1 <- map_text_coord(x = ts, flip_y = TRUE)
plot_charmap(cm_1)
# (b) pattern matching (regex):
cm_2 <- map_text_regex(ts, lbl_hi = "\\b\\w{4}\\b", bg_hi = "[good|test]",
lbl_rotate = "[^aeiou]", angle_fg = c(-45, +45))
plot_charmap(cm_2)
# (2) Alternative inputs:
# (a) From text string(s):
plot_charmap(ts)
# (b) From user input:
# plot_charmap() # (enter text in Console)
# (c) 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")
# plot_charmap(file = "test.txt")
# unlink("test.txt") # clean up (by deleting file).
Run the code above in your browser using DataLab