Skip to content

saving large matrices with decimal numbers

5 messages · Uwe Ligges, Moreno Ignazio Coco, PIKAL Petr

#
Hi everybody,

I am struggling to save txt. or csv. large sparse matrices (1024 X 768  
image size), initialized at 0.1.

  image1[0:10,0:10]
       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
  [1,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [2,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [3,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [4,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [5,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [6,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [7,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [8,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
  [9,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[10,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1

with small distributions located at different points of matrix.
If I try the same matrix but initialized at 0, it can save it.

It seems that R manages to save up around 800 X 600 decimal matrices  
but for bigger sizes the output is an empty file. Does anyone know  
whether there is a limit in saving such matrices and how can I work  
around this problem?

Thanks a lot,

Regards,

Moreno
#
Moreno Ignazio Coco wrote:
Please tell us what you did exactly when you got the empty file:
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Best wishes,
Uwe Ligges
#
well, that's exactly the point, I didn't do anything fancy or special,  
just save the matrix I gave you before (1024 X 768) either in format  
txt.

write.table(image, "~/mydata/blablabla/data.txt", col.names=F, row.names=F)

or csv:

write.csv (image, "~/mydata/blablabla/data.csv")


both cases the output is an empty file. Do you know what can be the problem?

Thanks a lot,

Moreno

  write.csv (image,   
"/afs/inf.ed.ac.uk/user/s07/s0788806/R/r_data/ProdEyeTrack/DataFrame/Clustered/Clut/Cluster1/Cl1Verb-tr.csv.1")



Quoting Uwe Ligges <ligges at statistik.tu-dortmund.de>:

  
    
#
Hi

image<-matrix(0.1, 768,1024)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [2,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [3,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [4,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [5,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [6,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [7,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [8,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 [9,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[10,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
 write.table(image, "temp.txt",col.names=F, row.names=F)

saved without problems to working directory. So I suspect that in your 
case it is a problem in specifying the output file. Couldn't  be the 
output file opened in some other programme?

regards
Petr

r-help-bounces at r-project.org napsal dne 04.09.2009 12:04:42:
http://www.R-project.org/posting-guide.html
row.names=F)
problem?
http://www.R-project.org/posting-guide.html
http://www.R-project.org/posting-guide.html
2 days later
#
Moreno Ignazio Coco wrote:
That's strange, because

  image <- matrix(0.1, 1024, 768)
  write.table(image, "~/data.txt", col.names=FALSE, row.names=FALSE)
  file.show("~/data.txt")

works fine for me.
Hence I suspect you did something very different, but since you have 
still not provided any piece of reproducible code, we cannot help.

Uwe Ligges