Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread Henrik Bengtsson
For the information: there were various ideas discussed around this in R-devel thread 'Base R examples that write to current working directory' started on 2018-03-29 (https://stat.ethz.ch/pipermail/r-devel/2018-March/075779.html). On Thu, Apr 26, 2018 at 10:31 AM, Jennifer Bryan

Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread Jennifer Bryan
One downside of all of this is that examples become increasingly dominated by code re: tempdir setup and the like. It may not discourage the people on this list, but I suspect too much extra machinery makes the typical user less likely to engage with examples. On Thu, Apr 26, 2018 at 10:04 AM,

Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread William Dunlap
The withr package has a bunch of simple functions executing code in various contexts, e.g., in a given directory or with given options() settings: > withr::with_dir function (new, code) { old <- setwd(dir = new) on.exit(setwd(old)) force(code) } > withr::with_dir(tempdir(), getwd())

Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread Duncan Murdoch
On 26/04/2018 1:04 PM, Henrik Bengtsson wrote: On Thu, Apr 26, 2018 at 6:28 AM, Spencer Graves wrote: On 2018-04-26 07:11, Jose A Guijarro wrote: El 25/04/18 a las 20:21, Duncan Murdoch escribió: On 25/04/2018 1:32 PM, Sarah Goslee wrote: Don't

Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread Henrik Bengtsson
On Thu, Apr 26, 2018 at 6:28 AM, Spencer Graves wrote: > > > On 2018-04-26 07:11, Jose A Guijarro wrote: >> >> El 25/04/18 a las 20:21, Duncan Murdoch escribió: >>> >>> On 25/04/2018 1:32 PM, Sarah Goslee wrote: Don't change the working directory!

Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread Duncan Murdoch
On 26/04/2018 9:28 AM, Spencer Graves wrote: On 2018-04-26 07:11, Jose A Guijarro wrote: El 25/04/18 a las 20:21, Duncan Murdoch escribió: On 25/04/2018 1:32 PM, Sarah Goslee wrote: Don't change the working directory! That has all kinds of unpleasant side effects for the unsuspecting user,

Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread Spencer Graves
On 2018-04-26 07:11, Jose A Guijarro wrote: El 25/04/18 a las 20:21, Duncan Murdoch escribió: On 25/04/2018 1:32 PM, Sarah Goslee wrote: Don't change the working directory! That has all kinds of unpleasant side effects for the unsuspecting user, possibly even more so than writing to a file.

Re: [R-pkg-devel] How to write example results to a tempdir()?

2018-04-26 Thread Jose A Guijarro
El 25/04/18 a las 20:21, Duncan Murdoch escribió: On 25/04/2018 1:32 PM, Sarah Goslee wrote: Don't change the working directory! That has all kinds of unpleasant side effects for the unsuspecting user, possibly even more so than writing to a file. Instead, write the file to the temp directory,