[R] Antwort: Re: Re: sink(): Cannot open file
jsorkin at grecc.umaryland.edu
Tue May 10 17:15:08 CEST 2016
I do not know what operating system you are working with, but when I use sink() under windows, I need to specify a valid path which I don't see in your code. I might, for example specify:
R code goes here
with the expectation that I would create a file myfile.txt that would contain the output of my R program.
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
Baltimore, MD 21201-1524
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
>>> <G.Maubach at weinwolf.de> 05/10/16 11:10 AM >>>
The program executes without warning or error. The file "all.Rout" is
begin created. Nothing will be written to it. The file is accessable
rights after the execution of the program by notepad.exe.
zz <- file("all.Rout", open = "wt")
sink(zz, type = "message")
creates the file, does not write anything to it and is not accessable
after program execution in R with notepad.exe.
Any ideas what happens behind the szenes?
Von: Jim Lemon <drjimlemon at gmail.com>
An: G.Maubach at weinwolf.de,
Kopie: r-help mailing list <r-help at r-project.org>
Datum: 10.05.2016 13:16
Betreff: Re: Re: [R] sink(): Cannot open file
Have you tried:
On Tue, May 10, 2016 at 9:05 PM, <G.Maubach at weinwolf.de> wrote:
> Hi Jim,
> thanks for your reply.
> ad 1)
> "all.Rout" was created in the correct directory. It exists properly with
> correct file properties on Windows, e.g. creation date and time and file
> size information.
> ad 2)
> I can not access the file with Notepad.exe directly after it was created
> by R. The error message is (translated):
> "Cannot access file "all.Rout". The file is opened by another process."
> ad 3)
> If I close R completely the file access is released. Then I can read the
> file using Notepad.exe. The contents is:
> Error in log("a") : non-numeric argument to mathematical function
> I tried
> but the error persists.
> To me it looks like R is still accessing the file and not releasing the
> connection for other programs. close(zz) should have solved the problem
> but unfortantely it doesn't.
> What else could I try?
> Kind regards
> Von: Jim Lemon <drjimlemon at gmail.com>
> An: G.Maubach at weinwolf.de,
> Kopie: r-help mailing list <r-help at r-project.org>
> Datum: 10.05.2016 12:50
> Betreff: Re: [R] sink(): Cannot open file
> Hi Georg,
> I don't suppose that you have:
> 1) checked that the file "all.Rout" exists somewhere?
> 2) if so, looked at the file with Notepad, perhaps?
> 3) let us in on the secret by pasting the contents of "all.Rout" into
> your message if it is not too big?
> At a guess, trying:
> might get you there.
> On Tue, May 10, 2016 at 5:25 PM, <G.Maubach at weinwolf.de> wrote:
>> Hi All,
>> I would like to route the output to a file using sink(). When using the
>> example from the ?sink documentation:
>> i <- 1:10
>> outer(i, i, "*")
>> ## capture all the output to a file.
>> zz <- file("all.Rout", open = "wt")
>> sink(zz, type = "message")
>> ## back to the console
>> sink(type = "message")
>> I can not open the file in Windows Explorer. The error message is:
>> "Cannot open file. File is in use be another proces."
>> How can I close the file in a manner that I can open it right after it
>> Kind regards
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
More information about the R-help