
Last chance! 50% off unlimited learning
Sale ends in
read_ascii
parses text inputs
(from a file or from user input in the Console)
into a character vector.
read_ascii(file = "", quiet = FALSE)
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 = ""
.
Boolean: Provide user feedback?
Default: quiet = FALSE
.
A character vector, with its elements denoting different lines of text.
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.
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
,
count_chars_words()
,
count_chars()
,
count_words()
,
l33t_rul35
,
map_text_chars()
,
map_text_coord()
,
map_text_regex()
,
metachar
,
text_to_chars()
,
text_to_sentences()
,
text_to_words()
,
transl33t()
# NOT RUN {
## 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).
# }
# NOT RUN {
## (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()
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab