[R] Antwort: Re: Antwort: Re: Re: sink(): Cannot open file

G.Maubach at weinwolf.de G.Maubach at weinwolf.de
Tue May 10 18:34:26 CEST 2016


Hi Sarah, John, Jim,
Hi All,

I have set my envrionment variable 

path <- file.path("H:", "2016", "Analysis")
setwd(dir = path)

This works well cause the file is created in that directory.

I have tried

close(zz)
unlink(zz)

and neither worked nor did it work out using them together.

I had this before when working with IBM SPSS Statistics. There was a 
workaround for the problem in SPSS.

Is there one for R?

Kind regards

Georg





Von:    Sarah Goslee <sarah.goslee at gmail.com>
An:     G.Maubach at weinwolf.de, 
Kopie:  r-help mailing list <r-help at r-project.org>
Datum:  10.05.2016 17:17
Betreff:        Re: [R] Antwort: Re: Re: sink(): Cannot open file



Try closing the type of sink you're actually opening:


zz <- file("all.Rout", open = "wt")
sink(zz, type = "message")
try(log("a"))
sink(type = "message")
close(zz)
unlink(zz)


If you look carefully at the example in?sink, there are two close
statements, one for each stream being sent to that file.

Sarah

----- Weitergeleitet von Georg Maubach/WWBO/WW/HAW am 10.05.2016 18:29 
-----

Von:    "John Sorkin" <jsorkin at grecc.umaryland.edu>
An:     <drjimlemon at gmail.com>, <G.Maubach at weinwolf.de>, 
Kopie:  <r-help at r-project.org>
Datum:  10.05.2016 17:20
Betreff:        Re: [R] Antwort: Re: Re: sink(): Cannot open file



George,
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:

sink("c:\myfile.txt")
 R code goes here
sink()
with the expectation that I would create a file myfile.txt that would 
contain the output of my R program.
 
John


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
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 



On Tue, May 10, 2016 at 11:05 AM,  <G.Maubach at weinwolf.de> wrote:
> Hi Jim,
>
> I tried:
>
> sink("all.Rout")
> try(log("a"))
> sink()
>
> 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.
>
> The program
>
> zz <- file("all.Rout", open = "wt")
> sink(zz, type = "message")
> try(log("a"))
> sink()
> close(zz)
> unlink(zz)
>
> 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?
>
> Kind regards
>
> Georg
>
>
>



More information about the R-help mailing list