Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mscan

Scan a Matrix


Description

Quickly scan a matrix from a file.

Usage

mscan(fname, nc = 0, header = FALSE, burn = 0, thin = 0, nlines = 0L,
        sep = "", ...)

Arguments

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'.

Details

This function is similar to read.table, but scanning a matrix of homogeneous data is much faster because there is much less format deduction.

Value

The matrix stored in the data file.

Author(s)

Examples

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

Boom

Bayesian Object Oriented Modeling

v0.9.7
LGPL-2.1 | file LICENSE
Authors
Steven L. Scott is the sole author and creator of the BOOM project. Some code in the BOOM libraries has been modified from other open source projects. These include Cephes (obtained from Netlib, written by Stephen L. Moshier), NEWUOA (M.J.D Powell, obtained from Powell's web site), and a modified version of the R math libraries (R core development team). Original copyright notices have been maintained in all source files. In these cases, copyright claimed by Steven L. Scott is limited to modifications made to the original code. Google claims copyright for code written while Steven L. Scott was employed at Google from 2008 - 2018, but BOOM is not an officially supported Google project.
Initial release
2021-02-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.