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.gos...@gmail.com> An: g.maub...@weinwolf.de, Kopie: r-help mailing list <r-help@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" <jsor...@grecc.umaryland.edu> An: <drjimle...@gmail.com>, <g.maub...@weinwolf.de>, Kopie: <r-help@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.maub...@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 > > > ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.