readMatrix: Read in numeric matrix from tab-delimited format written by...

View source: R/writeMatrix.R

readMatrixR Documentation

Read in numeric matrix from tab-delimited format written by writeMatrix

Description

readMatrix reads a matrix written by writeMatrix into a R session

Usage

readMatrix(file, row.names = TRUE, as.matrix = TRUE, ...)

Arguments

file

file to be read in

row.names

Logical, whether the first column contains row names (should be consistent with the setting in writeMatrix)

as.matrix

Logical, whether the data.frame object should be cast into a matrix

...

Other parameters passed to read.table, for instance stringsAsFactors. Following parameters are not allowed to change: header, sep, quote, dec, check.names, strip.wrhite, comment.char.

Details

Default behaviour of read.table is adapted to the convention used in writeMatrix

Value

Matrix when as.matrix is set to TRUE and otherwise data.frame

Examples

test.mat <- matrix(rnorm(1000), nrow=10, dimnames=list(LETTERS[1:10], 1:100))
tmpfile <- tempfile()
writeMatrix(test.mat, tmpfile)
readin.mat <- readMatrix(tmpfile)
if(require(ribiosUtils)) identicalMatrix(test.mat, readin.mat)

ribiosIO documentation built on Feb. 20, 2026, 5:09 p.m.