rasche@molgen.mpg.de
2005-Jun-15 11:56 UTC
[Rd] write.table confused by rownames/colnames (PR#7941)
Full_Name: Axel Rasche Version: 2.1.0 OS: Win2000 Submission from: (NULL) (141.14.21.81) Hi, write.table does not accept the second statement with <col.names = NA, row.names = FALSE>. I do not see why this should not be possible. test = matrix(1:4, 2, 2, dimnames = list( c("a","b"), c("c","d") )) write.table(test, file = "test.txt", sep = "\t", quote = FALSE, col.names = NA, row.names = FALSE) write.table(test, file = "test.txt", sep = "\t", quote = FALSE, col.names = NA) write.table(test, file = "test.txt", sep = "\t", quote = FALSE, col.names = TRUE, row.names = FALSE) write.table(test, file = "test.txt", sep = "\t", quote = FALSE, col.names = FALSE, row.names = FALSE) Thanks, Axel
ligges@statistik.uni-dortmund.de
2005-Jun-15 12:52 UTC
[Rd] write.table confused by rownames/colnames (PR#7941)
rasche at molgen.mpg.de wrote:> Full_Name: Axel Rasche > Version: 2.1.0 > OS: Win2000 > Submission from: (NULL) (141.14.21.81) > > > Hi, > > write.table does not accept the second statement with > <col.names = NA, row.names = FALSE>. > I do not see why this should not be possible. > > test = matrix(1:4, 2, 2, dimnames = list( c("a","b"), c("c","d") )) > write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = NA, row.names = FALSE)From my point of view one should not expect NA to work, but the help page says a "logical" is allowed and gives a correpsonding "NA" example, hence it is a bug, either in the help page or in the code. I'd vote for changing the help and depreciating NA for col.names/row.names, because I do not know what NA is expected to do and therefore I could not provide any bugfix for the code ... Uwe Ligges> write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = NA) > write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = TRUE, row.names = FALSE) > write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = FALSE, row.names = FALSE) > > Thanks, > Axel > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Prof Brian Ripley
2005-Jun-15 12:54 UTC
[Rd] write.table confused by rownames/colnames (PR#7941)
It seems that you are the one who is confused: the help file says By default there is no column name for a column of row names. If 'col.names = NA' a blank column name is added. If there are no row names, there is no point in adding a blank column name for them. So what did *you* think it would do? On Wed, 15 Jun 2005 rasche at molgen.mpg.de wrote:> Full_Name: Axel Rasche > Version: 2.1.0 > OS: Win2000 > Submission from: (NULL) (141.14.21.81) > > > write.table does not accept the second statement with > <col.names = NA, row.names = FALSE>. > I do not see why this should not be possible. > > test = matrix(1:4, 2, 2, dimnames = list( c("a","b"), c("c","d") )) > write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = NA, row.names = FALSE) > write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = NA) > write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = TRUE, row.names = FALSE) > write.table(test, file = "test.txt", sep = "\t", quote = FALSE, > col.names = FALSE, row.names = FALSE)-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
rasche@molgen.mpg.de
2005-Jun-15 13:11 UTC
[Rd] write.table confused by rownames/colnames (PR#7941)
Hello, Alright, I did not look at it that way I admit. I built a matrix with multiple row names (as a data.frame). Confusion started when exporting this as a spread-sheet. Now it all works fine. Thanks and sorry for the false alarm, Axel Prof Brian Ripley wrote:> It seems that you are the one who is confused: the help file says > > By default there is no column name for a column of row names. If > 'col.names = NA' a blank column name is added. > > If there are no row names, there is no point in adding a blank column > name for them. So what did *you* think it would do? > > On Wed, 15 Jun 2005 rasche at molgen.mpg.de wrote: > >> Full_Name: Axel Rasche >> Version: 2.1.0 >> OS: Win2000 >> Submission from: (NULL) (141.14.21.81) >> >> >> write.table does not accept the second statement with >> <col.names = NA, row.names = FALSE>. >> I do not see why this should not be possible. >> >> test = matrix(1:4, 2, 2, dimnames = list( c("a","b"), c("c","d") )) >> write.table(test, file = "test.txt", sep = "\t", quote = FALSE, >> col.names = NA, row.names = FALSE) >> write.table(test, file = "test.txt", sep = "\t", quote = FALSE, >> col.names = NA) >> write.table(test, file = "test.txt", sep = "\t", quote = FALSE, >> col.names = TRUE, row.names = FALSE) >> write.table(test, file = "test.txt", sep = "\t", quote = FALSE, >> col.names = FALSE, row.names = FALSE) > > >-- ******************************************* Dipl. Math. ETH Axel Rasche Max-Planck-Institute for Molecular Genetics Department Lehrach (Vertebrate Genomics) Ihnestrasse 63-73 D-14195 Berlin-Dahlem GERMANY Tel. ++49-30-8413-1289 Fax ++49-30-8413-1380