
Build a file-to-target-path plan for a Psych-DS-style layout
Source:R/psychds-file-plan.R
psychds_file_plan.RdMaps every file data_check found to the location it would occupy in a
Psych-DS-shaped layout: data files under data/, code under analysis/,
materials under materials/, documentation under documentation/ (or
documentation/codebooks/ for codebooks), the root readme/licence at the
collection root, and anything unclassified under unknown/. This is pure
file/folder organisation – it does not check Psych-DS compliance (that is
psychds_check()) and it does not write anything to disk.
Arguments
- structure_df
the
structuretable fromdata_check(one row per repository file, with at leastfile_name/file_path/data_type; thegroup/doc_role/referenced_bycolumns are used when present).- group_no_evidence
TRUE when no file path, repository split, or LLM answer named a study anywhere in this repository, so every file fell back to a single default study (
data_check's owngroup_no_evidenceoutput). Carried through to the return value only; does not affect the plan.
Value
a list with table (one row per file: file_name, data_type,
group, current_path, target_path, status – "present"/"move"/
"excluded" –, convert, original_target, referenced_by) and
group_no_evidence (passed through unchanged). table is an empty
data.frame when structure_df is NULL or has no rows.
Details
data_check assigns every file except the collection-level root README/
ro-crate-metadata.json to exactly one study group – deterministically
where path/repository/code-reference evidence allows, and via an LLM only
for the residual cases (see data_group_llm()). A multi-study repository
is modelled with a study-<group>/ directory per study (each a complete
Psych-DS dataset); only the root readme and licence sit at the collection
root beside them.
A tabular data file whose source is not already .csv (.xlsx/.sav/
.dta/...) is planned to be converted to .csv at its target path, with
the untouched original kept alongside it (convert/original_target
columns) – no conversion is actually performed here, only planned. A raw
(non-tabular) data file (.npy/.h5/...) keeps its own real name instead
of a _data.csv target, since it cannot be read as a table.
This is a pure function of structure_df: it takes no paper and makes no
data_check/module_run() call of its own, so callers resolve their own
structure_df (chained output, a saved build, or a fresh data_check run)
and pass it in directly – the same frame-dependent get_prev_outputs()
chain lookup every module relies on only works correctly one call deep from
module_run()'s own eval(), not from a second, ordinary function call
nested inside it.
Examples
paths <- list.files(demofile("repo"), recursive = TRUE)
structure_df <- data.frame(file_name = basename(paths), file_path = paths,
data_type = data_classify_files(basename(paths)))
psychds_file_plan(structure_df)$table[, c("file_name", "status", "target_path")]
#> file_name status target_path
#> 1 LICENSE move documentation/LICENSE
#> 2 README.md move documentation/README.md
#> 3 analysis.qmd move analysis/analysis.qmd
#> 4 clean_data.R move analysis/clean_data.R
#> 5 references.bib move documentation/references.bib
#> 6 stroop_raw.csv move data/raw/study-stroopraw_data.csv
#> 7 stroop_data.csv move data/study-stroopdata_data.csv
#> 8 dataset_description.json move data/dataset_description.json
#> 9 stroop_data_codebook.csv present documentation/stroop_data_codebook.csv
#> 10 renv.lock move analysis/renv.lock