Skip to content

write.matrix has limited line length -> truncation (PR#2722)

3 messages · christen@chemie.hu-berlin.de, Uwe Ligges, Brian Ripley

#
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.
2 days later
#
christen@chemie.hu-berlin.de wrote:
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
3 days later
#
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:
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:

            
There is no such version: did you misread 1.6.2?
Where is your evidence?  Perhaps the tools *you* used truncated the file?
Don't send suspicions: send real experimental data.