christen@chemie.hu-berlin.de
2003-Apr-03 08:49 UTC
[Rd] write.matrix has limited line length -> truncation (PR#2722)
Full_Name: Dr. Wolfgang Christen Version: 1.62 OS: Windows 2000 Submission from: (NULL) (141.20.76.99) I have a matrix of 705 x 999 elements and would like to save the data to a file using the follwing line: write.matrix ( format ( U1r, digits = 15 ), file = "C:\\Documents and Settings\\Administrator\\My Documents\\R\\plot-u2-2.txt" ) Then I had to find out that only 195 (out of 705) columns were saved :-( I tried then to reduce the accuracy to 5 digits, which gave me 373 columns, already better, but still insufficient. So my suspicion is that an internal line buffer is limited to something less than 4k and all subsequent data gets truncated and thus will not be saved.
Uwe Ligges
2003-Apr-05 16:04 UTC
[Rd] write.matrix has limited line length -> truncation (PR#2722)
christen@chemie.hu-berlin.de wrote:> Full_Name: Dr. Wolfgang Christen > Version: 1.62 > OS: Windows 2000 > Submission from: (NULL) (141.20.76.99) > > > I have a matrix of 705 x 999 elements and would like to save the data to a file > using the follwing line: > write.matrix ( format ( U1r, digits = 15 ), file = "C:\\Documents and > Settings\\Administrator\\My Documents\\R\\plot-u2-2.txt" ) > > Then I had to find out that only 195 (out of 705) columns were saved :-( > > I tried then to reduce the accuracy to 5 digits, which gave me 373 columns, > already better, but still insufficient. > > So my suspicion is that an internal line buffer is limited to something less > than 4k and all subsequent data gets truncated and thus will not be saved.I've just tried it out with a 1000x1000 matrix with R-1.6.2 on WinNT4.0: library(MASS) set.seed(123) write.matrix(matrix(format(rnorm(1000000), digits = 15), ncol = 1000), file = "c:/test.txt") It works! So could you provide an example (don't send a file, please!)? Uwe Ligges
Prof Brian Ripley
2003-Apr-08 20:26 UTC
(PR#2722) [Rd] Christen claimed `write.matrix has limited line length -> truncation', without a shred of evidence.
Is this the write.matrix from package MASS not being given due credit? If so, that uses cat, and if that has a line-length limit it is in the OS and not in R. (Some deficient OSes will have line-length limits under some circumstances, but I believe never less than 8095.) Under Linux:> A <- matrix(rnorm(705*10), 10) > library(MASS) > write.matrix(format(A, digits=15), file="foo") > q()Save workspace image? [y/n/c]: n gannet% wc foo 10 7050 155100 foo and that means there are 7050 entries in 10 lines of around 15k chars each. No evidence of truncation there! Under Windows XP I get identical results. BTW, please read the section on BUGS in the FAQ, and next time do send a reproducible example (and a non-zero amount of evidence for the claimed bug). BDR On Thu, 3 Apr 2003 christen@chemie.hu-berlin.de wrote:> Full_Name: Dr. Wolfgang Christen > Version: 1.62There is no such version: did you misread 1.6.2?> OS: Windows 2000 > Submission from: (NULL) (141.20.76.99) > > > I have a matrix of 705 x 999 elements and would like to save the data to a file > using the follwing line: > write.matrix ( format ( U1r, digits = 15 ), file = "C:\\Documents and > Settings\\Administrator\\My Documents\\R\\plot-u2-2.txt" ) > > Then I had to find out that only 195 (out of 705) columns were saved :-(Where is your evidence? Perhaps the tools *you* used truncated the file?> I tried then to reduce the accuracy to 5 digits, which gave me 373 columns, > already better, but still insufficient. > > So my suspicion is that an internal line buffer is limited to something less > than 4k and all subsequent data gets truncated and thus will not be saved.Don't send suspicions: send real experimental data. -- Brian D. Ripley, ripley@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