scan.text: scan.text

Description Usage Arguments Details Value Author(s)

Description

Read data into a vector or list from the console or file.

Usage

1
2
scan.text(file, blank.lines.skip = FALSE, strip.white = TRUE,
  quiet = TRUE, ...)

Arguments

file

the name of a file to read data values from. If the specified file is "", then input is taken from the keyboard (or whatever stdin() reads if input is redirected or R is embedded). (In this case input can be terminated by a blank line or an EOF signal, Ctrl-D on Unix and Ctrl-Z on Windows.)

Otherwise, the file name is interpreted relative to the current working directory (given by getwd()), unless it specifies an absolute path. Tilde-expansion is performed where supported. When running R from a script, file = "stdin" can be used to refer to the process's stdin file stream.

This can be a compressed file (see file).

Alternatively, file can be a connection, which will be opened if necessary, and if so closed at the end of the function call. Whatever mode the connection is opened in, any of LF, CRLF or CR will be accepted as the EOL marker for a line and so will match sep = "\n".

file can also be a complete URL. (For the supported URL schemes, see the ‘URLs’ section of the help for url.)

To read a data file not in the current encoding (for example a Latin-1 file in a UTF-8 locale or conversely) use a file connection setting its encoding argument (or scan's fileEncoding argument).

blank.lines.skip

logical: if TRUE blank lines in the input are ignored, except when counting skip and nlines.

strip.white

vector of logical value(s) corresponding to items in the what argument. It is used only when sep has been specified, and allows the stripping of leading and trailing ‘white space’ from character fields (numeric fields are always stripped). Note: white space inside quoted strings is not stripped.

If strip.white is of length 1, it applies to all fields; otherwise, if strip.white[i] is TRUE and the i-th field is of mode character (because what[i] is) then the leading and trailing unquoted white space from field i is stripped.

quiet

logical: if FALSE (default), scan() will print a line, saying how many items have been read.

...

arguments passed to scan

Details

This differs from base::scan, in that it automatically imports contents as character

Value

a character vector

Author(s)

Mark Cowley, 2012-07-06


drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.