Skip to content
Prev 4473 / 12125 Next

[R-pkg-devel] Fwd: Passing CRAN check when an examples must save a file

Dear all,
I had the same problem when I submitted my R package 'metan' to CRAN for
the first time.

"Please ensure that your functions do not write by default or in your
examples/vignettes/tests in the user's home filespace (including the
package directory and getwd()). In your examples/vignettes/tests you can
write to tempdir()"

I have several 'summary()' functions like:








*summary.waasb <- function(object, export = FALSE, file.name
<http://file.name> = "summary_waasb", ...) {  # do all I need here  if
(export == TRUE) {    sink(paste0(file.name <http://file.name>, ".txt"))
# do all I need here    sink()  }}*

All 'export' arguments are set to 'FALSE'. So, no file is generated in the
user's working directory.
Is the above function not according to the CRAN policies?

In two vignettes I have a code like:



*```{r, eval=FALSE }summary(stat_ge, export = TRUE)```*

Please, note that 'eval = FALSE'. Could this be the problem?
The suggestion is to write to a tempdir() but even looking at the Duncan
Murdoch's answer I cannot see how to do that in my case.
Looking for any suggestion.
Best regards,
Tiago Olivoto









---------- Forwarded message ---------
De: Duncan Murdoch <murdoch.duncan at gmail.com>
Date: sex, 27 de set de 2019 ?s 09:44
Subject: Re: [R-pkg-devel] Passing CRAN check when an examples must save a
file
To: Zachary Flynn <zlflynn at gmail.com>, <r-package-devel at r-project.org>
On 26/09/2019 11:43 p.m., Zachary Flynn wrote:
write
Save the file to the temporary directory, ?.g.

   filename <- file.path(tempdir(), "Prod?c.csv")
   write.csv(something, file = filename)

You could clean up at the end of the example with

   unlink(filename)

but you shouldn't rely on this alone to prevent the error:  if you're
writing files, you should *only* be doing it in the temporary directory.

Duncan Murdoch

______________________________________________
R-package-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel