The functions scan_txt()
and scan_txt2()
, which take no arguments,
can be used to scan a text string from the console.
Value
A character vector of length one that contains the string that has been scanned from the console.
Details
After the function call, R will continue scanning your input until it encounters an empty input line, i.e. until it encounters two consecutive newline symbols (or until it encounters a line with nothing but whitespace characters). In other words, press ENTER twice in a row if you want to stop inputting characters. The function will then return your input as a character vector of length one.
These functions are designed to allow you to input complex text, in particular
regular expressions, without dealing with the restrictions of string literals,
such as having to use \\
for \
.