Read Matrix Data
read.matrix.RdReads a matrix data file.
Arguments
- file
the name of the file which the data are to be read from.
- header
a logical value indicating whether the file contains the names of the columns as its first line.
- sep
the field separator character. Values on each line of the file are separated by this character.
- skip
the number of lines of the data file to skip before beginning to read data.
Details
Usually each row of the file represents an observation and each column contains a variable. The first row possibly contains the names of the variables (columns).
read.matrix might be more efficient than
read.table for very large data sets.
Examples
x <- matrix(0, 10, 10)
write(x, "test", ncolumns=10)
x <- read.matrix("test")
x
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0 0 0 0 0 0 0 0 0 0
#> [2,] 0 0 0 0 0 0 0 0 0 0
#> [3,] 0 0 0 0 0 0 0 0 0 0
#> [4,] 0 0 0 0 0 0 0 0 0 0
#> [5,] 0 0 0 0 0 0 0 0 0 0
#> [6,] 0 0 0 0 0 0 0 0 0 0
#> [7,] 0 0 0 0 0 0 0 0 0 0
#> [8,] 0 0 0 0 0 0 0 0 0 0
#> [9,] 0 0 0 0 0 0 0 0 0 0
#> [10,] 0 0 0 0 0 0 0 0 0 0
unlink("test")