mscan | R Documentation |
Quickly scan a matrix from a file.
mscan(fname, nc = 0, header = FALSE, burn = 0, thin = 0, nlines = 0L,
sep = "", ...)
fname |
The name of the file from which to scan the data. |
nc |
The number of columns in the matrix to be read. If zero then the number of columns will be determined by the number of columns in the first line of the file. |
header |
logical indicating whether the file contains a header row. |
burn |
An integer giving the number of initial lines of the matrix to discard. |
thin |
An integer. If thin > 1 then keep every thin\'th line. This is useful for reading in very large files of MCMC output, for example. |
nlines |
If positive, the number of data lines to scan from the data file (e.g. for an MCMC algorithm that is only partway done). Otherwise the entire file will be read. |
sep |
Field separator in the data file. |
... |
Extra arguments passed to 'scan'. |
This function is similar to read.table
, but scanning a
matrix of homogeneous data is much faster because there is much less
format deduction.
The matrix stored in the data file.
Steven L. Scott steve.the.bayesian@gmail.com
filename <- file.path(tempdir(), "example.data")
cat("foo bar baz", "1 2 3", "4 5 6", file = filename, sep = "\n")
m <- mscan(filename, header = TRUE)
m
## foo bar baz
## [1,] 1 2 3
## [2,] 4 5 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.