Skip to content
Prev 3853 / 12125 Next

[R-pkg-devel] Writing to files without altering working directory in R package

I find the idea of using setwd in examples disturbing, because I try to avoid using setwd at all as a way to delegate my choice of working directory to the operating system actions taken when starting R. In other words, I recommend to  beginners that they start R in their working directory and leave it there all the time, using relative paths as much as possible. Since examples are likely to be run in the middle of an analysis in order to develop the next step in the analysis, leaving my wd elsewhere would be counterproductive. Having a leftover variable that tells me where the data were written is simpler than using setwd to and from the temp directory. More hand holding than that belongs in a tutorial or vignette.

Note that if you wrap the example up in a vignette then changing to the temp directory seems fair to me (if CRAN allows it) because the context is more like  a complete, self-contained analysis.
On May 7, 2019 11:32:49 AM PDT, Henrik Bengtsson <henrik.bengtsson at gmail.com> wrote: