map_text_coord {ds4psy}R Documentation

map_text_coord maps the characters of a text string into a table (with x/y-coordinates).

Description

map_text_coord parses text (from a text string x) into a table that contains a row for each character and x/y-coordinates corresponding to the character positions in x.

Usage

map_text_coord(x, flip_y = FALSE, sep = "")

Arguments

x

The text string(s) to map (required). If length(x) > 1, elements are mapped to different lines (i.e., y-coordinates).

flip_y

Boolean: Should y-coordinates be flipped, so that the lowest line in the text file becomes y = 1, and the top line in the text file becomes y = n_lines? Default: flip_y = FALSE.

sep

Character to insert between the elements of a multi-element character vector as input x? Default: sep = "" (i.e., add nothing).

Details

map_text_coord creates a data frame with 3 variables: Each character's x- and y-coordinates (from top to bottom) and a variable char for the character at these coordinates.

Note that map_text_coord was originally a part of read_ascii, but has been separated to enable independent access to separate functionalities.

Value

A data frame with 3 variables: Each character's x- and y-coordinates (from top to bottom) and a variable char for the character at this coordinate.

See Also

map_text_regex for mapping text to a character table and matching patterns; plot_charmap for plotting character maps; plot_chars for creating and plotting character maps; read_ascii for parsing text from file or user input.

Other text objects and functions: Umlaut, capitalize(), caseflip(), cclass, chars_to_text(), collapse_chars(), count_chars_words(), count_chars(), count_words(), invert_rules(), l33t_rul35, map_text_chars(), map_text_regex(), metachar, read_ascii(), text_to_chars(), text_to_sentences(), text_to_words(), transl33t(), words_to_text()

Examples

map_text_coord("Hello world!")             # 1 line of text
map_text_coord(c("Hello", "world!"))       # 2 lines of text
map_text_coord(c("Hello", " ", "world!"))  # 3 lines of text
 

## Read text from file:

## Create a temporary file "test.txt":
# cat("Hello world!", "This is a test.",
#     "Can you see this text?", "Good! Please carry on...",
#      file = "test.txt", sep = "\n")
 
# txt <- read_ascii("test.txt")
# map_text_coord(txt)

# unlink("test.txt")  # clean up (by deleting file). 



[Package ds4psy version 1.0.0 Index]