Message-ID: <Pine.LNX.4.61.0503071820180.7898@gannet.stats>
Date: 2005-03-07T18:22:39Z
From: Brian Ripley
Subject: Writing to a file
In-Reply-To: <3A822319EB35174CA3714066D590DCD50994E7F4@usrymx25.merck.com>
On Mon, 7 Mar 2005, Liaw, Andy wrote:
> Would the following do?
>
> x <- 1000
> write.table(Info[Info[,4] > x, c(1, 4)], file="/tmp/CT.dat")
>
> Andy
>
>> From: Melanie Vida
>>
>> Here is a simple question. Is there a quicker way to write to a file
>> several rows of data at a time rather than one line at a
>> time? How can
>> the code below be optimized to write several rows at a time to a file
>> rather than one line at a time. See my slow method of
>> write.table below:
There is almost no penalty in writing a line at a time *if* you open a
connection and write to that. It might save you if Andy's solution runs
you out of memory. I would investigate doing this is large blocks of rows
in that case.
>>
>> ---------------------------
>> x<-1000
>> for( i in 1:385420)
>> (
>> if(Info[i,4] > x)
>> write.table (cbind(Info[i,1], Info[i,4], file="/tmp/CT.dat",
>> append=TRUE, row.names=FALSE, col.names=FALSE)
>>
>> Thanks,
>>
>> -Melanie
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>>
>>
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
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