| Line 412... |
Line 412... |
| 412 |
@section XML
|
412 |
@section XML
|
| 413 |
@cindex XML
|
413 |
@cindex XML
|
| 414 |
|
414 |
|
| 415 |
When reading data from text files, it is the responsibility of the user
|
415 |
When reading data from text files, it is the responsibility of the user
|
| 416 |
to know and to specify the conventions used to create that file,
|
416 |
to know and to specify the conventions used to create that file,
|
| 417 |
e.g. the comment character, whether a header line is present, the value
|
417 |
e.g.@: the comment character, whether a header line is present, the value
|
| 418 |
separator, the representation for missing values (and so on) described
|
418 |
separator, the representation for missing values (and so on) described
|
| 419 |
in @ref{Export to text files}. A markup language which can be used to
|
419 |
in @ref{Export to text files}. A markup language which can be used to
|
| 420 |
describe not only content but also the structure of the content can
|
420 |
describe not only content but also the structure of the content can
|
| 421 |
make a file self-describing, so that one need not provide these details
|
421 |
make a file self-describing, so that one need not provide these details
|
| 422 |
to the software reading the data.
|
422 |
to the software reading the data.
|
| Line 774... |
Line 774... |
| 774 |
Function @code{scan} has many arguments, most of which we have already
|
774 |
Function @code{scan} has many arguments, most of which we have already
|
| 775 |
covered under @code{read.table}. The most crucial argument is
|
775 |
covered under @code{read.table}. The most crucial argument is
|
| 776 |
@code{what}, which specifies a list of modes of variables to be read
|
776 |
@code{what}, which specifies a list of modes of variables to be read
|
| 777 |
from the file. If the list is named, the names are used for the
|
777 |
from the file. If the list is named, the names are used for the
|
| 778 |
components of the returned list. Modes can be numeric, character or
|
778 |
components of the returned list. Modes can be numeric, character or
|
| 779 |
complex, and are usually specified by an example, e.g. @code{0},
|
779 |
complex, and are usually specified by an example, e.g.@: @code{0},
|
| 780 |
@code{""} or @code{0i}. For example
|
780 |
@code{""} or @code{0i}. For example
|
| 781 |
|
781 |
|
| 782 |
@example
|
782 |
@example
|
| 783 |
cat("2 3 5 7", "11 13 17 19", file="ex.dat", sep="\n")
|
783 |
cat("2 3 5 7", "11 13 17 19", file="ex.dat", sep="\n")
|
| 784 |
scan(file="ex.dat", what=list(x=0, y="", z=0), flush=TRUE)
|
784 |
scan(file="ex.dat", what=list(x=0, y="", z=0), flush=TRUE)
|
| Line 2097... |
Line 2097... |
| 2097 |
@findex seek
|
2097 |
@findex seek
|
| 2098 |
@findex isSeekable
|
2098 |
@findex isSeekable
|
| 2099 |
The generic function @code{seek} can be used to read and (on some
|
2099 |
The generic function @code{seek} can be used to read and (on some
|
| 2100 |
connections) reset the current position for reading or writing.
|
2100 |
connections) reset the current position for reading or writing.
|
| 2101 |
Unfortunately it depends on OS facilities which may be unreliable
|
2101 |
Unfortunately it depends on OS facilities which may be unreliable
|
| 2102 |
(e.g. with text files under Windows). Function @code{isSeekable}
|
2102 |
(e.g.@: with text files under Windows). Function @code{isSeekable}
|
| 2103 |
reports if @code{seek} can change the position on the connection
|
2103 |
reports if @code{seek} can change the position on the connection
|
| 2104 |
given by its argument.
|
2104 |
given by its argument.
|
| 2105 |
|
2105 |
|
| 2106 |
@findex truncate
|
2106 |
@findex truncate
|
| 2107 |
The function @code{truncate} can be used to truncate a file opened for
|
2107 |
The function @code{truncate} can be used to truncate a file opened for
|
| Line 2137... |
Line 2137... |
| 2137 |
written to the file as a stream of bytes exactly as it is represented in
|
2137 |
written to the file as a stream of bytes exactly as it is represented in
|
| 2138 |
memory.
|
2138 |
memory.
|
| 2139 |
|
2139 |
|
| 2140 |
@code{readBin} reads a stream of bytes from the file and interprets them
|
2140 |
@code{readBin} reads a stream of bytes from the file and interprets them
|
| 2141 |
as a vector of mode given by @code{what}. This can be either an object
|
2141 |
as a vector of mode given by @code{what}. This can be either an object
|
| 2142 |
of the appropriate mode (e.g. @code{what=integer()}) or a character
|
2142 |
of the appropriate mode (e.g.@: @code{what=integer()}) or a character
|
| 2143 |
string describing the mode (one of the five given in the previous
|
2143 |
string describing the mode (one of the five given in the previous
|
| 2144 |
paragraph or @code{"double"} or @code{"int"}). Argument @code{n}
|
2144 |
paragraph or @code{"double"} or @code{"int"}). Argument @code{n}
|
| 2145 |
specifies the maximum number of vector elements to read from the
|
2145 |
specifies the maximum number of vector elements to read from the
|
| 2146 |
connection: if fewer are available a shorter vector will be returned.
|
2146 |
connection: if fewer are available a shorter vector will be returned.
|
| 2147 |
Argument @code{signed} allows 1-byte and 2-byte integers to be
|
2147 |
Argument @code{signed} allows 1-byte and 2-byte integers to be
|