Skip to contents

Every script runs in the repository as the authors organised it, with every file at its own path, from the folder .repro_run_folders() chooses. A reference is then:

  • left as written when it names a file's path from the top ("raw_data/scan1/log.csv"), also when other files share the name (20 scan folders each with a log.csv), and when it is a relative path that names no file and no file with its name was found, or the file found has a path that ends in the path as written: the code probably joins it with a folder of its own (os.path.join(base, "fig7/x.csv")), and rewriting it to the full path gave processed_data/fig7/processed_data/fig7/x.csv;

  • rewritten to the one file with its name elsewhere in the repository when it names no file as written ("./data/x.csv" with the file in exploratory/): the authors moved or left out a folder when they deposited;

  • rewritten to the file's path from the top when it names a file relative to the script's own folder (source("helpers.R"), "../raw_data/scores.csv"), since the script does not run from there;

  • rewritten as repro_rewrite_paths() found, by the file's name, when it is an absolute path (Z:/Strontium/... on the author's computer) or goes up out of the package.

Usage

.repro_keep_working_refs(
  rw,
  plan,
  script_path = NA_character_,
  run_dir = ".",
  here_dir = "."
)

Arguments

rw

a repro_rewrite_paths() result for one script

plan

the package layout's plan (.repro_package_plan())

script_path

the script's own path in the package

run_dir

the folder the script runs from, from the top of the package (see .repro_run_folders()); a reference works as written when it names a file counted from there, and a rewritten path is counted from there too

here_dir

the folder here() starts in, from the top of the package (see .repro_here_start()): a path that is the one argument of here() (in_here) counts from there, not from run_dir

Value

rw with a logical as_written column

Details

A reference left as written is marked as_written; it is not counted as rewritten, and not as a missing input, unless it names no file and no file with its name is in the repository. Another exception is a file the package has only inside an archive, read at the path unpacking it would give: as the package is, that path does not exist, so the reference is not found, and the file becomes a missing input (in_archive in repro_missing_inputs()).