[R-pkg-devel] appropriate directory for data downloads in examples, demos and vignettes

Jonathan Callahan jonathan at mazamascience.com
Mon Jun 29 17:25:03 CEST 2015


Hi,

The MazamaSpatialUtils
<http://cran.r-project.org/package=MazamaSpatialUtils> package has a
required "package state" variable which users set to specify where they
want to store large amounts of GIS data that is being downloaded and
converted by the package. The implementation of this follows Hadley's
advice here:

http://adv-r.had.co.nz/Environments.html#explicit-envs

The functionality is implemented with package environment and getter and
setter functions:

spatialEnv <- new.env(parent = emptyenv())
spatialEnv$dataDir <- NULL


getSpatialDataDir <- function() {
  if (is.null(spatialEnv$dataDir)) {
    stop('No data directory found. Please set a data directory with
setSpatialDataDir("YOUR_DATA_DIR").',call.=FALSE)
  } else {
    return(spatialEnv$dataDir)
  }
}


setSpatialDataDir <- function(dataDir) {
  old <- spatialEnv$dataDir
  dataDir <- path.expand(dataDir)
  tryCatch({
    if (!file.exists(dataDir)) dir.create(dataDir)
    spatialEnv$dataDir <- dataDir
  }, warning = function(warn) {
    warning("Invalid path name.")
  }, error   = function(err) {
    stop(paste0("Error in setSpatialDataDir(",dataDir,")."))
  })
  return(invisible(old))
}


My question is:

*What is an appropriate directory to specify for vignettes (or demos or
examples) that need to go through CRAN testing?*

The R code in vignettes need to specify a directory that is writable during
the package build process but that will also be available to users.

Should we create a /tmp/<hash> directory? Would that be available on all
systems?

Alternatively,

*What is an alternative to vignettes and demos for tutorial scripts that
should not be tested upon submission to CRAN?*


Thanks for any suggestions.

Jon


-- 
Jonathan Callahan, PhD
Mazama Science
206-708-5028
mazamascience.com

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list