You could try:

   as.matrix( read.table( filename ) )


Date: Mon, 05 Jan 2004 14:54:30 -0500 
From: John Hayes <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]> 
Subject: [R] loading matrix from file 

 
 
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

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to