read_ascii {ds4psy}R Documentation

read_ascii parses text (from file or user input) into string(s) of text.

Description

read_ascii parses text inputs (from a file or from user input in the Console) into a character vector.

Usage

read_ascii(file = "", quiet = FALSE)

Arguments

file

The text file to read (or its path). If file = "" (the default), scan is used to read user input from the Console. If a text file is stored in a sub-directory, enter its path and name here (without any leading or trailing "." or "/"). Default: file = "".

quiet

Boolean: Provide user feedback? Default: quiet = FALSE.

Details

Different lines of text are represented by different elements of the character vector returned.

The getwd function is used to determine the current working directory. This replaces the here package, which was previously used to determine an (absolute) file path.

Note that read_ascii originally contained map_text_coord, but has been separated to enable independent access to separate functionalities.

Value

A character vector, with its elements denoting different lines of text.

See Also

map_text_coord for mapping text to a table of character coordinates; plot_chars for a character plotting function.

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_coord(), map_text_regex(), metachar, text_to_chars(), text_to_sentences(), text_to_words(), transl33t(), words_to_text()

Examples

## 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")

## (a) Read text (from file): 
# read_ascii("test.txt")
# read_ascii("test.txt", quiet = TRUE)  # y flipped

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

## (b) Read text (from file in subdir):
# read_ascii("data-raw/txt/ascii.txt")  # requires txt file

## (c) Scan user input (from console):
# read_ascii()



[Package ds4psy version 1.0.0 Index]