Nigel Birney
2009-Apr-26 23:38 UTC
[R] Unable to re-import a table that was just exported to a file
Hi all, I am saving a program's output to a file to be read by another algorithm. But somehow such a simple operation (the reading) fails. I get: Error in read.table("a_corr_data.txt", sep = ",", col.names = T, row.names F) : more columns than column names Here is the write statement: write.table(a_corr_data,"a_corr_data.txt",sep=",",col.names=T,row.names=F) Here is the read statement: a_corr_data <- read.table("a_corr_data.txt",sep=",",col.names=T,row.names=F) Nothing happens in-between (these actions are just 10-30 secs apart). I tried to export/import without col.names, also tried different deliminators ("/t") but the same error pops up again and again. I am already quite unhappy with this. thanks, N. -- View this message in context: http://www.nabble.com/Unable-to-re-import-a-table-that-was-just-exported-to-a-file-tp23248010p23248010.html Sent from the R help mailing list archive at Nabble.com.
jim holtman
2009-Apr-27 11:05 UTC
[R] Unable to re-import a table that was just exported to a file
Take a look at the output file. You may need 'header=TRUE' on the read.table. It would be good to at least supply the first couple of lines of the file that you are trying to read. The error message is self explanitory: you have more columns than there are names on the first line. On Sun, Apr 26, 2009 at 7:38 PM, Nigel Birney <nan23 at cam.ac.uk> wrote:> > Hi all, > > I am saving a program's output to a file to be read by another algorithm. > But somehow such a simple operation (the reading) fails. I get: > > Error in read.table("a_corr_data.txt", sep = ",", col.names = T, row.names > F) : > ?more columns than column names > > > Here is the write statement: > > > write.table(a_corr_data,"a_corr_data.txt",sep=",",col.names=T,row.names=F) > > Here is the read statement: > > a_corr_data <- > read.table("a_corr_data.txt",sep=",",col.names=T,row.names=F) > > Nothing happens in-between (these actions are just 10-30 secs apart). I > tried to export/import without col.names, also tried different deliminators > ("/t") but the same error pops up again and again. I am already quite > unhappy with this. > > thanks, > > N. > > -- > View this message in context: http://www.nabble.com/Unable-to-re-import-a-table-that-was-just-exported-to-a-file-tp23248010p23248010.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?