[R] sink() does not seem to release the file

BXC (Bendix Carstensen) bxc at novonordisk.com
Tue Jan 2 11:57:36 CET 2001


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:

> version
         _              
platform i386-pc-mingw32
arch     x86            
os       Win32          
system   x86, Win32     
status                  
major    1              
minor    2.0            
year     2000           
month    12             
day      15             
language R              
> sink("foo")
> cat("some text")
> sink()
> shell("type foo")
some text
> shell("dir f*")
 Volume in drive N is Local Disk
 Volume Serial Number is 1C5E-3A70

 Directory of N:\Bendix\Steno\JaSv\iddm

02-01-2001  11:33                    9 foo
               1 File(s)              9 bytes
               0 Dir(s)  172.857.344.000 bytes free
> shell("del foo")
N:\Bendix\Steno\JaSv\iddm\foo
The process cannot access the file because it is being used by another
process.


However, when I fire up my old R 1.01.1 (which is not installed under
Win2000,
but merely a verbatim copy from my old NT4 machine), I get:

> version
         _         
platform Windows   
arch     x86       
os       Win32     
system   x86, Win32
status             
major    1         
minor    1.1       
year     2000      
month    August    
day      15        
language R         
> sink("oof")
> cat("any text")
> sink()
> shell("type oof")
any text
> shell("dir oo*")
 Volume in drive N is Local Disk
 Volume Serial Number is 1C5E-3A70

 Directory of N:\Bendix\Steno\JaSv\iddm

02-01-2001  11:37                    8 oof
               1 File(s)              8 bytes
               0 Dir(s)  172.857.339.904 bytes free
> shell("del oof")
> shell("dir oo*")
 Volume in drive N is Local Disk
 Volume Serial Number is 1C5E-3A70

 Directory of N:\Bendix\Steno\JaSv\iddm

File Not Found
Warning message: 
cmd execution failed with error code 1 in: shell("dir oo*") 
> 

Is this a new bug or a new facility??

I have a vague recollection that a similar problem was also present in an
older version of R, too.
The workaround in R 1.2 is to:

> shell("copy foo oof")

and then use oof for the relevant purpose.

The background for this is that I use R to write a small SAS-program
that writes a SAS-dataset in a read.table format, that I then read into
R. But when strted from withn R, SAS complains that the program file just 
sink()ed by R is in use (apparently by R). 

Any one interested can get the rather clumsy sas.get.R and the corresponding
%out SAS-macro from me on request. Requires that SAS is on your macine 
as well. No bells and whistles at all.

Bendix Carstensen

----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Centre
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 28 25 87 38
fax: +45 44 43 73 13
bxc at novo.dk
www.biostat.ku.dk/~bxc
----------------------




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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