rjournal / rjtools

Tools for AUTHORS to use for checking and submitting articles to the R Journal
https://rjournal.github.io/rjtools/
Other
31 stars 14 forks source link

`check_packages_available` reports base packages #41

Open djvanderlaan opened 2 years ago

djvanderlaan commented 2 years ago

I use the parallel package in a paper. initial_check_article reports that I didn't use CRANpkg or BIOpkg:

ℹ NOTE: 1 package(s) used in the text without CRANpkg or BIOpkg commands: parallel

However, parallel isn't on CRAN as it is in base.R so I use a plain \pkg to name the package.

dicook commented 2 years ago

Oh, are you using the old latex template or the new Rmarkdown template. If Rmarkdown you would use backticks. In latex, yes, the \pkg is appropriate to use. Make a note in the letter to editor about the initial_check_article() error. Thanks for checking your article!

djvanderlaan commented 2 years ago

Sorry forgot to mention that I am indeed using the latex template. This paper has been in the pipeline for a while, didn't know about the rmarkdown option untill now. And even now, it is not mentioned in the author instructions. And also on https://journal.r-project.org/submissions.html I initially read over it (perhaps make it a separate section).

Woiuld it be an option to change the following code in check_packages_available

  pkgs_used <- stringr::str_sub(
    unlist(
      stringr::str_extract_all(string = tex, "pkg\\{(.*?)\\}")),
    start = 5, end = -2)

  # Start with full list of pkgs
  declared_pkgs <- pkgs_used %in% c(CRANpkgs, BIOpkgs)

  if (any(!declared_pkgs)) {
    # Look for pkgs that were used in the text but did not have a CRANpkg{} commands
    pkgs_missing_ref <- unique(pkgs_used[!(declared_pkgs)])
    amount_missing <- length(pkgs_missing_ref)

    log_note("{amount_missing} package(s) used in the text without CRANpkg or BIOpkg commands: {paste(pkgs_missing_ref, collapse = ', ')}")
  }

into something like:

  pkgs_used <- stringr::str_sub(
    unlist(
      stringr::str_extract_all(string = tex, "pkg\\{(.*?)\\}")),
    start = 5, end = -2)

  pkgs_used <- setdiff(pkgs_used, r_base_packages)

  # Start with full list of pkgs
  declared_pkgs <- pkgs_used %in% c(CRANpkgs, BIOpkgs)

  if (any(!declared_pkgs)) {
    # Look for pkgs that were used in the text but did not have a CRANpkg{} commands
    pkgs_missing_ref <- unique(pkgs_used[!(declared_pkgs)])
    amount_missing <- length(pkgs_missing_ref)

    log_note("{amount_missing} package(s) used in the text without CRANpkg or BIOpkg commands: {paste(pkgs_missing_ref, collapse = ', ')}")
  }

#....

r_base_packages <- c("base",
    "compiler",
    "datasets",
    "graphics",
    "grDevices",
    "grid",
    "methods",
    "parallel",
    "splines",
    "stats",
    "stats4",
    "tcltk",
    "tools",
    "translations",
    "utils")

That would capture cases like this. Another option would be to only report the note when the declared_packages are also in allCRANpkgs or allBIOpkgs.