The code_check module analyses the code files shared with a paper. Building on the file list from repo_check, it identifies code files (R, SAS, SPSS, Stata), then checks each for signs of reproducibility problems: whether files parse without errors, whether they contain comments, whether they use absolute file paths (which break on other machines), whether files they try to load are actually present in the repository, and whether libraries are loaded in multiple places rather than in a single block near the top of the script (loading imports in one place makes a script’s dependencies easy to see).
Note
This module makes live network calls to retrieve and inspect code files from the linked repositories. You need an internet connection to run the code below.
#>
#> - We found 4 R, 0 SAS, 0 SPSS, and 0 Stata code files.
#> - All your code files had comments.
#> - 4 files loaded in the code were missing in the repository.
#> - Absolute file paths were found.
#> - Libraries/imports were loaded in multiple places.
#> - No parsing issues of R-type files were found.
The table has one row per code file, with the reproducibility checks as columns:
code_check shares repo_check’s local-file options, plus a limit on how many files to inspect:
# inspect at most 5 files (default is 20)module_run(paper, "code_check", file_limit =5)# check code in a local folder only, no online lookupsmodule_run(paper, "code_check", local_path ="path/to/files", local_only =TRUE)
See the Local Files chapter for a full walkthrough of checking local code, including cloud-synced folders.
21.5 Notes
The module reports on potential problems. An absolute path or a missing file is not always an error — but it is usually worth a second look if you want the analysis to be reproducible.