Risk Report and Metric

code
Stats
R
Reproduce
Author

Zhenglei Gao

Published

December 6, 2024

Since I began working on an internal project that utilizes a validated R environment provided by a third-party vendor, I started considering the need for an open-source image or repository that is validated and can be used by both industry and regulatory authorities. In my search, I discovered that others are already working on this initiative, and I decided to join the R Validation Hub repository working group. This is voluntary work I do in my free time. However, I would appreciate if the group can be sponsored by industry association and this can be part of my job.

Testing the Idea

  1. Install the package
pak::pak("pharmaR/riskreports")
  1. Start generating a report

The riskreports package is developed by the R validation hub repo working group.

packageVersion("riskreports")
library(riskreports)
options("riskreports_output_dir" = ".")
pr <- package_report(
  package_name = "dplyr",
  package_version = "1.1.4",
  params = list(
    assessment_path = system.file("assessments/dplyr.rds", package = "riskreports")),
  quiet = TRUE # To silence quarto output for readability
)

Generate a summary report

I would prefer having also a summarize report in the end for the QA to check. I don’t think the QA would check every single validation report for the handreds of packages included in the image.

tmp_packages_file <- tempfile("packages")
repo_packages_url <- "https://raw.githubusercontent.com/pharmaR/pharmapkgs/refs/heads/main/inst/repos/src/contrib/PACKAGES"
download.file(repo_packages_url, tmp_packages_file)
tmp <- read.dcf(tmp_packages_file)
colnames(tmp)
 [1] "Package"               "Version"               "Depends"              
 [4] "Suggests"              "License"               "MD5sum"               
 [7] "NeedsCompilation"      "DownloadURL"           "has_news"             
[10] "news_current"          "exported_namespace"    "has_vignettes"        
[13] "export_help"           "has_website"           "has_maintainer"       
[16] "size_codebase"         "has_source_control"    "has_bug_reports_url"  
[19] "downloads_1yr"         "reverse_dependencies"  "has_examples"         
[22] "dependencies"          "Imports"               "bugs_status"          
[25] "LinkingTo"             "Enhances"              "assess_size_codebase" 
[28] "License_restricts_use" "OS_type"               "Priority"             
[31] "Path"                  "License_is_FOSS"       "Archs"                
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
knitr::kable(t(head(tmp))) %>% kableExtra::kable_classic(.) 
Package A3 AalenJohansen AATtools ABACUS abasequence abbreviate
Version 1.0.0 1.0 0.0.3 1.0.0 0.1.0 0.1
Depends R (>= 2.15.0), xtable, pbapply NA R (>= 3.6.0) R (>= 3.1.0) NA NA
Suggests randomForest, e1071 knitr, rmarkdown NA rmarkdown (>= 1.13), knitr (>= 1.22) NA testthat (>= 3.0.0)
License GPL (>= 2) GPL (>= 2) GPL-3 GPL-3 GPL-3 GPL-3
MD5sum 027ebdd8affce8f0effaecfcd5f5ade2 d7eb2a6275daa6af43bf8a980398b312 ea8127d953ca6a2f118ea49441772af6 50c54c4da09307cb95a70aaaa54b9fbd 1392d909eb0f65be94fd4160a371ae21 37285eddefb6b0fce95783bf21b32999
NeedsCompilation no no no no no no
DownloadURL https://github.com/cran/A3/archive/refs/tags/1.0.0.tar.gz https://github.com/cran/AalenJohansen/archive/refs/tags/1.0.tar.gz https://github.com/cran/AATtools/archive/refs/tags/0.0.3.tar.gz https://github.com/cran/ABACUS/archive/refs/tags/1.0.0.tar.gz https://github.com/cran/abasequence/archive/refs/tags/0.1.0.tar.gz https://github.com/cran/abbreviate/archive/refs/tags/0.1.tar.gz
has_news 0 0 0 0 0 0
news_current 0 0 0 0 0 0
exported_namespace 0.777299861174691 0.693596453153698 0.386057808916704 0.643035173277501 0.666185565559974 0.731058578630005
has_vignettes 0 1 0 1 0 0
export_help NaN 1 1 1 1 1
has_website 0 0 0 1 0 1
has_maintainer 1 1 1 1 1 1
size_codebase 0.29126213592233 0.485436893203884 0.0949968334388854 0.842696629213483 0.700934579439252 0.746268656716418
has_source_control 0 0 0 0 0 1
has_bug_reports_url 0 0 1 0 0 0
downloads_1yr 0.100811068416289 0.0360950281781554 0.0371777754955325 0.0274265707060883 0.0283086091857226 0.0685081226091708
reverse_dependencies 0.246376140522644 0.246376140522644 0.246376140522644 0.246376140522644 0.246376140522644 0.246376140522644
has_examples 0.923076923076923 1 1 1 1 1
dependencies 0.731058578630005 0.880797077977882 0.5 0.731058578630005 0.880797077977882 0.880797077977882
Imports NA NA magrittr, dplyr, doParallel, foreach ggplot2 (>= 3.1.0), shiny (>= 1.3.1), NA NA
bugs_status NA NA 0 NA NA NA
LinkingTo NA NA NA NA NA NA
Enhances NA NA NA NA NA NA
assess_size_codebase NA NA NA NA NA NA
License_restricts_use NA NA NA NA NA NA
OS_type NA NA NA NA NA NA
Priority NA NA NA NA NA NA
Path NA NA NA NA NA NA
License_is_FOSS NA NA NA NA NA NA
Archs NA NA NA NA NA NA

Testing pharmapkgs

repo <- "C:/Projects/Rlib/pharmapkgs/repos/src/contrib/"
packages <- get_packages(
      base_url = system.file("repos", package = "pharmapkgs", mustWork = TRUE)
    )

available.packages(repos = repo, fields = risk_fields(repo)) |>
  tibble::as_tibble()