[R] sink() does not seem to release the file
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Jan 2 12:32:03 CET 2001
"BXC (Bendix Carstensen)" <bxc at novonordisk.com> writes:
> I run Win2000, and when I try to write to a file and later use it
> it seems that R 1.02.0 has a firm grip on it:
[Proof deleted]
This was on the R-devel list 2 weeks ago:
On Tue, 19 Dec 2000, Prof Brian D Ripley wrote:
> On Tue, 19 Dec 2000 Setzer.Woodrow at epamail.epa.gov wrote:
>
> > When I use sink(filename) to save the results of the run, the file
> > does not seem to be closed or released back to the OS after I issue
> > the "sink()" command. Here is a baby example:
>
> sink works on connections, not files, as from 1.2.0.
>
> > sink("test.txt")
> > tdta <- data.frame(x = x <- 0:10,y = 2 * x + rnorm(11))
> >
> > print(summary(lm(y ~ x, data=tdta)))
> > sink()
> >
> > At this point (even after refreshing the Explorer window) the filesize of
> > "test.txt" is listed as 0 bytes, and as long as Rgui is running, I
> > cannot delete the file. Emacs cannot read the file (but Notepad can). This happens both in the gui
> > and when the commands are in a file run via "source()".
>
> Yes, but what is the bug exactly? The connection is still open so you can
> switch output back to it. If you want different behaviour, you can open a
> connection and close it yourself. As in
>
> zz <- file("test.txt", "w")
> sink(zz)
> tdta <- data.frame(x = x <- 0:10,y = 2 * x + rnorm(11))
> print(summary(lm(y ~ x, data=tdta)))
> sink()
> close(zz)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list