[R] How to more efficently read in a big matrix

Gabor Grothendieck ggrothendieck at gmail.com
Mon Nov 12 00:04:01 CET 2007


On Nov 11, 2007 2:28 PM, affy snp <affysnp at gmail.com> wrote:
> Hi Gabor,
>
> I replaced multiple spaces with a single one and tried
> the code you suggested. I got:
>
> > library(sqldf)
> Loading required package: RSQLite
> Loading required package: DBI
> Loading required package: gsubfn
> Loading required package: proto
> > source("http://sqldf.googlecode.com/svn/trunk/R/sqldf.R")
> > myfile <- file("243_47mel_withnormal_expression_log2.txt")
> > stmt <- read.table(myfile, nr = 1, as.is = TRUE)
> > stmt <- stmt[regexpr("call", stmt) < 0]
> > stmt <- paste("select", paste(stmt, collapse = ","), "from myfile")
> > myfile <- file("243_47mel_withnormal_expression_log2.txt")
> > DF <- sqldf(stmt, file.format = list(sep = " "))
> Error in try({ :
>  RS-DBI driver: (RS_sqlite_import:
> ./243_47mel_withnormal_expression_log2.txt line 6651 expected 488
> columns of data but found 641)

The error message says that its expecting 488 columns
but found 641 columns on line 6651.  Examine line 6651 to see
what is wrong.

Also try it with just the first few rows of the file and if that works
that is even greater evidence that there is something unexpected with
your file.



More information about the R-help mailing list