ices-tools-prod / icesTAF

Functions to support the ICES Transparent Assessment Framework
GNU General Public License v3.0
5 stars 7 forks source link

utility function to return bootstrap/data folder #21

Closed colinpmillar closed 4 years ago

colinpmillar commented 4 years ago

Something like the following would be useful to use in bootstrap scripts and taf scripts. Because these are run in different working directories and the user should work in the root directory, this function will make the development of bootstrap scripts easier on the user.

taf.data.path <- function(..., fsep = .Platform$file.sep) {
  if (basename(dirname(dirname(getwd()))) == "bootstrap") {
    args <- list("..")
  } else {
    args <- list("bootstrap", "data")
  }
  do.call(file.path, c(args, ..., fsep = fsep))
}

usage example:

my_data <- read.taf(taf.data.path("my_script_folder", "my_data.csv"))
colinpmillar commented 4 years ago

provided with: https://github.com/ices-tools-prod/icesTAF/commit/2a1849ff652718943e570dd1143c74ed3fd4bf63