[R] issues with "write.table"

Foadi, J (James) james.foadi at diamond.ac.uk
Wed Oct 8 13:19:04 CEST 2008

Dear R gurus and users,
I'm having problems with the use of write.table.
I have a 28-variables data frame create at each cycle of a loop; it can contain between 2000 and 3000 rows for each cycle.
After each cycle the data frame is written out to a file with the "append=TRUE" option and then removed from memory.
These are the couple of lines involved:

> data2 <- format.data.frame(sorted_data)
> write.table(data2,file="R_toscala.txt",append=TRUE,quote=FALSE,sep="\t",row.names=FALSE,col.names=FALSE)
> rm(tmp,new_xyz,u0,u1,data,data0,data1,data2,data3,data4,templ0,templ1,f0,f1,frac,Xdet,Ydet,tthr,tth,tras_coef,sc,srs,sup,sdown,rs,lorentz,pola,rot,sorted_data)

You can see that data2 is removed at each cycle together with other objects in order to free memory.

Now everything is OK when the written file, "R_toscala.txt" grows roughly to 100000 lines. But my code writes wrong values after that. I suspect there might
be issues with files size or with stack size, but am absolutely not sure about it. I am running Ubuntu 8 - 64bit. The ulimit -a gives:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 40960
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 40960
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Any idea of what is going wrong here?

Many thanks,


Dr James Foadi PhD
Membrane Protein Laboratory (MPL)
Diamond Light Source Ltd
Diamond House
Harewell Science and Innovation Campus
Chilton, Didcot
Oxfordshire OX11 0DE

Email    :  james.foadi at diamond.ac.uk
Alt Email:  j.foadi at imperial.ac.uk

<DIV><FONT size="1" color="gray">This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom

More information about the R-help mailing list