Skip to contents

An R package repository (or a package kept in a subfolder of a larger repository) is not itself research data or analysis code – it is reusable software infrastructure, and its .R files, DESCRIPTION, NAMESPACE, man/, and tests/ are package scaffolding rather than the study's data/code. Detected by the standard CRAN/R-package fingerprint: a DESCRIPTION file containing a Package: field, plus a NAMESPACE file, both directly inside the same folder. Only that folder's own fingerprint is checked (not, say, DESCRIPTION and NAMESPACE sitting in two different folders that happen to share a repository).

Usage

.is_r_package_file(file_path)

Arguments

file_path

a character vector of repo-relative file paths (as found in all_files$file_path, all belonging to the same repo_url)

Value

a logical vector, same length as file_path: TRUE for every file that is part of a detected R package (the DESCRIPTION/NAMESPACE themselves, plus their standard package subdirectories) AND that package is being excluded (root-level packages are only excluded when real content survives outside them; nested packages are always excluded).

Details

A repository can hold more than one R package (e.g. a monorepo of packages), and a package can sit in a subfolder rather than at the repository root, so detection runs per folder rather than assuming the whole repository is-or-isn't a package.

Detection works from file NAMES alone (no download needed): a DESCRIPTION file and a NAMESPACE file directly inside the same folder is the fingerprint every R package has, whether on CRAN or in a git repository that has been through devtools::document()/R CMD build at least once. Only files that are actually PART of the package – DESCRIPTION/ NAMESPACE themselves, and anything under that folder's R/, man/, tests/, vignettes/, data/, inst/, or src/ subdirectories – are candidates for exclusion; a sibling file sitting directly in the same folder (e.g. a study's analysis.R kept alongside a package it depends on) is NOT swept in just because it shares that folder.

A package detected at the REPOSITORY ROOT is only excluded if at least one file OUTSIDE it classifies (via data_classify_files(), the same rules- based classifier data_check itself uses) as real "data" or "code" – not merely present, since packaging scaffolding (.gitignore, LICENSE, README, a Flowchart.png a README embeds, *.Rproj, CI config, etc.) commonly sits alongside a package's DESCRIPTION/NAMESPACE without being the study's own content. This distinguishes two real cases that both fingerprint as "DESCRIPTION+NAMESPACE at the root": a study that shares its own data and analysis code AS an R package (the package IS the deposit – nothing to exclude, since nothing data/code-shaped lives outside the package for the study's content to be) versus a study's repository that happens to bundle a vendored copy of someone else's package alongside the study's own files (here the vendored package's DESCRIPTION/NAMESPACE sits alongside the study's own real data/code, so only the vendored package's own files are excluded). A package detected in a NESTED subfolder is always excluded regardless of this check, since by construction there is always an "outside" for a nested package (at minimum, the parent folder itself).