Skip to content

loading matrix from file

2 messages · John Hayes, Andy Bunn

#
What is the best way to load a matrix from a text file if it's already
in a matrix form?  I'd like the parser function to automagically
recognize that line separators indicate a new row.  The technique I've
been using is the following:

output <- matrix(scan(inputFile), byrow=T, ncol=2)

However, I don't want to have to specify ncol=2.  

Thanks!

John
#
What's wrong with read.table? It's the principal function for reading
data into R.
-Andy