### Install riskmetric from GitHub Source: https://github.com/pharmar/riskmetric/blob/master/README.md Use this command with the devtools package to install the riskmetric package directly from GitHub. ```r devtools::install_github("pharmaR/riskmetric") ``` -------------------------------- ### Check Suggests Dependency Installation Source: https://github.com/pharmar/riskmetric/wiki/Adding-Metrics-from-External-Packages Use this utility function to check for the presence of a dependency package and prompt the user to install it if necessary. It's expected to be the first line in S3 generics for Suggests-backed assessments and pkg_ref_cache functions. ```R validate_suggests_install("security") ``` -------------------------------- ### Install riskmetric from CRAN Source: https://github.com/pharmar/riskmetric/blob/master/README.md Use this command to install the riskmetric package from the Comprehensive R Archive Network (CRAN). ```r install.packages("riskmetric") ``` -------------------------------- ### pkg_library() Source: https://context7.com/pharmar/riskmetric/llms.txt Creates a `pkg_cohort` containing `pkg_ref` objects for every package in a given library directory, enabling bulk risk assessment of all installed packages. ```APIDOC ## pkg_library() ### Description Creates a `pkg_cohort` containing `pkg_ref` objects for every package found in a given library directory, enabling bulk risk assessment of all installed packages at once. ### Usage ```r pkg_library(library_path) ``` ### Parameters * `library_path`: The path to the R library directory. ### Request Example ```r library(riskmetric) library(dplyr) # Assess all packages in the first library path lib_cohort <- pkg_library(.libPaths()[1]) # Run the full assessment pipeline on the whole library result <- lib_cohort %>% pkg_assess() %>% pkg_score() # Identify highest-risk packages result %>% arrange(desc(pkg_score)) %>% select(package, version, pkg_score) %>% head(10) ``` ### Response Returns a `pkg_cohort` object containing `pkg_ref` objects for all packages in the specified library. ``` -------------------------------- ### Set Package-Level Option to Skip Install Prompt Source: https://github.com/pharmar/riskmetric/wiki/Adding-Metrics-from-External-Packages Set this package-level option to prevent repeated prompts for installing a Suggests dependency within a single session. The option name follows the pattern `skip_{dependency_name}_install`. ```R options(skip_security_install = TRUE) ``` -------------------------------- ### Fit Cox Model with Elastic Net Regularization (R) Source: https://github.com/pharmar/riskmetric/blob/master/tests/testthat/test_webmocks/data/cran_package_checks.html Demonstrates fitting a Cox regression model with elastic net regularization for a path of lambda values using the cox.path function. This example includes setup for sparse matrices and may encounter errors related to foreign function calls. ```r set.seed(2) nobs <- 100; nvars <- 15 xvec <- rnorm(nobs * nvars) xvec[sample.int(nobs * nvars, size = 0.4 * nobs * nvars)] <- 0 x <- matrix(xvec, nrow = nobs) beta <- rnorm(nvars / 3) fx <- x[, seq(nvars / 3)] %*% beta / 3 ty <- rexp(nobs, exp(fx)) tcens <- rbinom(n = nobs, prob = 0.3, size = 1) jsurv <- survival::Surv(ty, tcens) fit1 <- glmnet:::cox.path(x, jsurv) ``` ```r # works with sparse x matrix x_sparse <- Matrix::Matrix(x, sparse = TRUE) fit2 <- glmnet:::cox.path(x_sparse, jsurv) ``` -------------------------------- ### Assess R Package Risk Source: https://github.com/pharmar/riskmetric/blob/master/README.md This example demonstrates how to use riskmetric to assess the risk of specified R packages. It involves referencing packages, assessing them, and then scoring the assessment. Ensure 'dplyr' and 'riskmetric' libraries are loaded. ```r library(dplyr) library(riskmetric) pkg_ref(c("riskmetric", "utils", "tools")) %>% pkg_assess() %>% pkg_score() ``` -------------------------------- ### Silent Zero Error Handling in pkg_score Source: https://context7.com/pharmar/riskmetric/llms.txt This example shows how to configure `pkg_score` to silently handle failed metrics by returning a score of 0 without issuing warnings. ```R pkg_ref("brokenpackage") %>% pkg_assess() %>% pkg_score(error_handler = score_error_zero) ``` -------------------------------- ### Create Package Reference with pkg_ref() Source: https://context7.com/pharmar/riskmetric/llms.txt Use pkg_ref() to create a package reference object. It auto-detects the package source (installed, CRAN, Bioconductor, local source) but can be overridden. It also supports creating a list of references for tibble-based pipelines. ```r library(riskmetric) # Auto-detect source: checks installed packages first, then CRAN/Bioc ref_installed <- pkg_ref("dplyr") ref_installed$source # "pkg_install" # Force CRAN remote lookup ref_cran <- pkg_ref("ggplot2", source = "pkg_cran_remote") ref_cran$source # "pkg_cran_remote" # Reference local source code directory ref_source <- pkg_ref("/path/to/mypackage") ref_source$source # "pkg_source" # Reference a Bioconductor package ref_bioc <- pkg_ref("Biobase", source = "pkg_bioc_remote") # Specify a specific library location ref_lib <- pkg_ref("utils", source = "pkg_install", lib.loc = .libPaths()[1]) # Multiple packages at once → list_of_pkg_ref (used in tibble pipeline) refs <- pkg_ref(c("dplyr", "ggplot2", "tidyr")) class(refs) # "list_of_pkg_ref" ``` -------------------------------- ### pkg_ref() — Create a Package Reference Source: https://context7.com/pharmar/riskmetric/llms.txt This function is the entry point for the riskmetric workflow. It creates a package reference object by accepting a package name or a path to source code. The source is auto-detected but can be overridden. It can also handle multiple packages to produce a list of package references for tibble-based pipelines. ```APIDOC ## pkg_ref() — Create a Package Reference ### Description Entry point for the entire workflow. Accepts a package name or a path to source code and returns a `pkg_ref` S3 object (with a source-specific subclass: `pkg_install`, `pkg_source`, `pkg_cran_remote`, `pkg_bioc_remote`, or `pkg_missing`). The source is auto-detected but can be overridden with the `source` argument. Accepts a character vector or list to produce a `list_of_pkg_ref` suitable for tibble-based pipelines. ### Usage ```r library(riskmetric) # Auto-detect source: checks installed packages first, then CRAN/Bioc ref_installed <- pkg_ref("dplyr") ref_installed$source # "pkg_install" # Force CRAN remote lookup ref_cran <- pkg_ref("ggplot2", source = "pkg_cran_remote") ref_cran$source # "pkg_cran_remote" # Reference local source code directory ref_source <- pkg_ref("/path/to/mypackage") ref_source$source # "pkg_source" # Reference a Bioconductor package ref_bioc <- pkg_ref("Biobase", source = "pkg_bioc_remote") # Specify a specific library location ref_lib <- pkg_ref("utils", source = "pkg_install", lib.loc = .libPaths()[1]) # Multiple packages at once → list_of_pkg_ref (used in tibble pipeline) refs <- pkg_ref(c("dplyr", "ggplot2", "tidyr")) class(refs) # "list_of_pkg_ref" ``` ``` -------------------------------- ### Assess an Entire R Library Source: https://context7.com/pharmar/riskmetric/llms.txt Creates a `pkg_cohort` for all packages in a library directory to enable bulk risk assessment. Requires 'riskmetric' and 'dplyr'. ```r library(riskmetric) library(dplyr) # Assess all packages in the first library path lib_cohort <- pkg_library(.libPaths()[1]) # Run the full assessment pipeline on the whole library result <- lib_cohort %>% pkg_assess() %>% pkg_score() # Identify highest-risk packages result %>% arrange(desc(pkg_score)) %>% select(package, version, pkg_score) %>% head(10) ``` -------------------------------- ### Unit Test for Suggests Assessments Source: https://github.com/pharmar/riskmetric/wiki/Adding-Metrics-from-External-Packages This unit test verifies that Suggests-backed assessment functions and their metrics are added correctly according to the design specification. It checks package-level options, attributes on assessment generics, and the appropriate call to `validate_suggests_install`. ```R test_that("Suggests assessments are correctly implemented", { # Check that package-level options are set correctly expect_true(getOption("skip_security_install")) expect_true(getOption("skip_lintr_install")) # Check that attributes are correctly set on the assessment_* generics expect_equal(attr(riskmetric::assess_security, "suggests_dependency"), "security") expect_equal(attr(riskmetric::assess_lintr, "suggests_dependency"), "lintr") # Check that validate_suggests_install is appropriately called # (This part of the test would involve mocking or inspecting function calls, # which is beyond a simple code snippet) # For demonstration, we'll assume the check is conceptually present. # In a real test, you'd use testthat::with_mocked_bindings or similar. # Example conceptual check: # expect_called(riskmetric:::validate_suggests_install, n = 1, "security") # expect_called(riskmetric:::validate_suggests_install, n = 1, "lintr") }) ``` -------------------------------- ### Individual Metric Assessments Source: https://context7.com/pharmar/riskmetric/llms.txt Demonstrates calling individual `assess_*` functions to inspect raw metric data before scoring. Each function accepts a `pkg_ref` object and returns a `pkg_metric` subclass. ```r library(riskmetric) ref <- pkg_ref("dplyr") # NEWS file presence (score: 1 if present, else 0) assess_has_news(ref) # Vignettes presence (score: 1 if any, else 0) assess_has_vignettes(ref) # Maintainer presence (score: 1 if any, else 0) assess_has_maintainer(ref) # Source control URL presence (score: 1 if any, else 0) assess_has_source_control(ref) # Bug reports URL presence (score: 1 if present, else 0) assess_has_bug_reports_url(ref) # Proportion of exported functions with documented examples (score: 0.0–1.0) assess_has_examples(ref) # Whether NEWS is updated for the current version (score: 1 if current, else 0) assess_news_current(ref) # 1-year CRAN download count (logistic score; ~150k downloads ≈ 0.5) assess_downloads_1yr(ref) # Dependency footprint (logistic score; more deps → lower score) assess_dependencies(ref) # Reverse dependency count (logistic score; more rev-deps → higher score) assess_reverse_dependencies(ref) # Codebase size in lines of code (logistic score; larger → lower score) assess_size_codebase(ref) # Unit test coverage via covr (pkg_source only; score = totalcoverage / 100) ref_src <- pkg_ref("/path/to/mypackage") assess_covr_coverage(ref_src) # Status of last 30 bug reports (score = fraction closed) assess_last_30_bugs_status(ref) # License detected (returns NA_real_; scoring deferred pending consensus) assess_license(ref) # Score any single metric object directly metric_score(assess_has_news(ref)) # 1 metric_score(assess_downloads_1yr(ref)) # e.g. 0.94 ``` -------------------------------- ### Assess Packages with pkg_assess() Source: https://context7.com/pharmar/riskmetric/llms.txt Apply assessment functions to package references using pkg_assess(). It can assess single or multiple packages and allows specifying a subset of assessments. Custom error handlers can be provided. ```r library(riskmetric) library(dplyr) # Assess a single package with all default assessments pkg_ref("riskmetric") %>% pkg_assess() # Returns a list_of_pkg_metric # Assess multiple packages as a tibble (one row per package) pkg_ref(c("dplyr", "tidyr", "purrr")) %>% pkg_assess() # Returns a tibble with columns: pkg_ref, has_news, has_vignettes, # has_maintainer, has_source_control, downloads_1yr, etc. # Run only a specific subset of assessments pkg_ref("ggplot2") %>% pkg_assess( assessments = get_assessments(c( "assess_has_news", "assess_has_vignettes", "assess_has_maintainer", "assess_downloads_1yr" )) ) # Custom error handler: silently skip failed assessments pkg_ref("riskmetric") %>% pkg_assess(error_handler = assessment_error_empty) ``` -------------------------------- ### Retrieve and Use Assessment Functions Source: https://context7.com/pharmar/riskmetric/llms.txt Lists all available assessment functions using `all_assessments()` and retrieves a specific subset using `get_assessments()`. These can then be used with `pkg_assess()`. ```r library(riskmetric) # List all available assessment functions assessments <- all_assessments() names(assessments) # [1] "assess_covr_coverage" "assess_dependencies" # [3] "assess_downloads_1yr" "assess_export_help" # [5] "assess_has_bug_reports_url" "assess_has_examples" # [7] "assess_has_maintainer" "assess_has_news" # [9] "assess_has_source_control" "assess_has_vignettes" # [11] "assess_has_website" "assess_last_30_bugs_status" # [13] "assess_license" "assess_news_current" # [15] "assess_r_cmd_check" "assess_remote_checks" # [17] "assess_reverse_dependencies" "assess_size_codebase" # Get a specific subset my_assessments <- get_assessments(c("assess_has_news", "assess_has_vignettes")) pkg_ref("ggplot2") %>% pkg_assess(assessments = my_assessments) %>% pkg_score() ``` -------------------------------- ### Pango Font Warning (System) Source: https://github.com/pharmar/riskmetric/blob/master/tests/testthat/test_webmocks/data/cran_package_checks.html Shows system-level warnings from Pango related to font rendering issues, specifically 'failed to create cairo scaled font' and 'invalid matrix (not invertible)'. These warnings indicate potential problems with font configuration or scaling, leading to 'ugly output'. ```system (process:18845): Pango-WARNING **: failed to create cairo scaled font, expect ugly output. the offending font is 'Helvetica Medium 9' (process:18845): Pango-WARNING **: font_face status is: (process:18845): Pango-WARNING **: scaled_font status is: invalid matrix (not invertible) (process:18845): Pango-WARNING **: shaping failure, expect ugly output. shape-engine='BasicEngineFc', font='Helvetica Medium 9', text='m' ``` -------------------------------- ### Individual assess_* Functions Source: https://context7.com/pharmar/riskmetric/llms.txt These functions perform per-metric assessments on a `pkg_ref` object, returning a `pkg_metric` subclass. They can be called individually to inspect raw metric data before scoring. ```APIDOC ## Individual assess_* Functions ### Description Each `assess_*` function accepts a `pkg_ref` object and returns a `pkg_metric` subclass. They can be called individually to inspect raw metric data before scoring. ### Usage ```r assess_has_news(pkg_ref_object) assess_has_vignettes(pkg_ref_object) assess_has_maintainer(pkg_ref_object) assess_has_source_control(pkg_ref_object) assess_has_bug_reports_url(pkg_ref_object) assess_has_examples(pkg_ref_object) assess_news_current(pkg_ref_object) assess_downloads_1yr(pkg_ref_object) assess_dependencies(pkg_ref_object) assess_reverse_dependencies(pkg_ref_object) assess_size_codebase(pkg_ref_object) assess_covr_coverage(pkg_source_ref_object) assess_last_30_bugs_status(pkg_ref_object) assess_license(pkg_ref_object) ``` ### Parameters * `pkg_ref_object`: A `pkg_ref` object representing the package to assess. * `pkg_source_ref_object`: A `pkg_ref` object for a package source, required for `assess_covr_coverage`. ### Request Example ```r library(riskmetric) ref <- pkg_ref("dplyr") # NEWS file presence assess_has_news(ref) # Vignettes presence assess_has_vignettes(ref) # Maintainer presence assess_has_maintainer(ref) # Source control URL presence assess_has_source_control(ref) # Bug reports URL presence assess_has_bug_reports_url(ref) # Proportion of exported functions with documented examples assess_has_examples(ref) # Whether NEWS is updated for the current version assess_news_current(ref) # 1-year CRAN download count assess_downloads_1yr(ref) # Dependency footprint assess_dependencies(ref) # Reverse dependency count assess_reverse_dependencies(ref) # Codebase size in lines of code assess_size_codebase(ref) # Unit test coverage via covr (pkg_source only) ref_src <- pkg_ref("/path/to/mypackage") assess_covr_coverage(ref_src) # Status of last 30 bug reports assess_last_30_bugs_status(ref) # License detected assess_license(ref) # Score any single metric object directly metric_score(assess_has_news(ref)) # 1 metric_score(assess_downloads_1yr(ref)) # e.g. 0.94 ``` ### Response Each function returns a `pkg_metric` subclass object representing the assessment result for that specific metric. ``` -------------------------------- ### all_assessments() and get_assessments() Source: https://context7.com/pharmar/riskmetric/llms.txt Functions to retrieve and manage assessment functions. `all_assessments()` lists all available assessment functions, while `get_assessments()` retrieves a specific subset by function name. ```APIDOC ## all_assessments() and get_assessments() ### Description `all_assessments()` returns a named list of all exported `assess_*` functions available in the riskmetric namespace. `get_assessments()` retrieves a specific subset by function name, for use with `pkg_assess()`. ### Usage ```r all_assessments() get_assessments(assessment_names) ``` ### Parameters * `assessment_names`: A character vector of assessment function names to retrieve. ### Request Example ```r library(riskmetric) # List all available assessment functions assessments <- all_assessments() names(assessments) # Get a specific subset my_assessments <- get_assessments(c("assess_has_news", "assess_has_vignettes")) pkg_ref("ggplot2") %>% pkg_assess(assessments = my_assessments) %>% pkg_score() ``` ### Response `all_assessments()` returns a named list of all assessment functions. `get_assessments()` returns a list of the specified assessment functions. ``` -------------------------------- ### pkg_assess() — Apply Assessment Functions Source: https://context7.com/pharmar/riskmetric/llms.txt This function applies a list of `assess_*` functions to a package reference object or a tibble of package references. It returns a tibble with one column per assessment, where each cell contains a `pkg_metric` object. By default, all exported `assess_*` functions are used. ```APIDOC ## pkg_assess() — Apply Assessment Functions ### Description Applies a list of `assess_*` functions to a `pkg_ref` object or a tibble of package references and returns a tibble with one column per assessment. Each cell is a `pkg_metric` object. By default, all exported `assess_*` functions are used via `all_assessments()`. Use `get_assessments()` to run only a specific subset. ### Usage ```r library(riskmetric) library(dplyr) # Assess a single package with all default assessments pkg_ref("riskmetric") %>% pkg_assess() # Returns a list_of_pkg_metric # Assess multiple packages as a tibble (one row per package) pkg_ref(c("dplyr", "tidyr", "purrr")) %>% pkg_assess() # Returns a tibble with columns: pkg_ref, has_news, has_vignettes, # has_maintainer, has_source_control, downloads_1yr, etc. # Run only a specific subset of assessments pkg_ref("ggplot2") %>% pkg_assess( assessments = get_assessments(c( "assess_has_news", "assess_has_vignettes", "assess_has_maintainer", "assess_downloads_1yr" )) ) # Custom error handler: silently skip failed assessments pkg_ref("riskmetric") %>% pkg_assess(error_handler = assessment_error_empty) ``` ``` -------------------------------- ### Default Error Handling in pkg_score Source: https://context7.com/pharmar/riskmetric/llms.txt This snippet demonstrates the default behavior of `pkg_score` when encountering errors in metrics. It will issue warnings and return a score of 0 for failed metrics. ```R pkg_ref("brokenpackage") %>% pkg_assess() %>% pkg_score(error_handler = score_error_default) ``` -------------------------------- ### Score Package Assessments with pkg_score() Source: https://context7.com/pharmar/riskmetric/llms.txt Convert assessment results into numeric scores (0-1) and compute a composite pkg_score using pkg_score(). It supports custom error handling for scoring and can score individual metric objects. ```r library(riskmetric) library(dplyr) # Full pipeline: reference → assess → score result <- pkg_ref(c("riskmetric", "dplyr", "Rcpp")) %>% pkg_assess() %>% pkg_score() # View composite risk scores result %>% select(package, version, pkg_score) # # A tibble: 3 × 3 # package version pkg_score # riskmetric 0.2.6 0.312 # dplyr 1.1.4 0.089 # Rcpp 1.0.12 0.041 # Score with custom error handling (NA instead of 0 for failed metrics) result_na <- pkg_ref("newpkg") %>% pkg_assess() %>% pkg_score(error_handler = score_error_NA) # Score a single pkg_metric object metric_score(assess_has_news(pkg_ref("riskmetric"))) # [1] 1 ``` -------------------------------- ### Silent NA Error Handling in pkg_score Source: https://context7.com/pharmar/riskmetric/llms.txt Use this configuration for `pkg_score` to distinguish between metrics that failed to compute (resulting in NA) and those that scored 0. No warnings are issued for failed metrics. ```R pkg_ref("brokenpackage") %>% pkg_assess() %>% pkg_score(error_handler = score_error_NA) ``` -------------------------------- ### summarize_scores() Source: https://context7.com/pharmar/riskmetric/llms.txt Aggregates per-metric numeric scores into a single composite risk value per package. It calculates risk as 1 minus the weighted quality score and accepts an optional weights vector. ```APIDOC ## summarize_scores() ### Description Combines all per-metric numeric scores in a scored tibble into a single composite risk value per package. Risk = 1 − weighted quality score. Accepts an optional `weights` vector to emphasize or de-emphasize specific metrics. ### Usage ```r summarize_scores(scored_tibble, weights = NULL) ``` ### Parameters * `scored_tibble`: A scored tibble containing per-metric scores. * `weights` (optional): A numeric vector to specify weights for different metrics. ### Request Example ```r library(riskmetric) library(dplyr) scored <- pkg_ref(c("riskmetric", "dplyr")) %>% pkg_assess() %>% pkg_score() # Default equal weighting summarize_scores(scored) # Custom weights emphasizing downloads and vignettes custom_weights <- c( downloads_1yr = 3, has_vignettes = 2, has_news = 1, has_maintainer = 1, has_source_control = 1 ) summarize_scores(scored, weights = custom_weights) ``` ### Response Returns a numeric vector representing the composite risk score(s). ``` -------------------------------- ### Vignette Re-building Warning (R Markdown) Source: https://github.com/pharmar/riskmetric/blob/master/tests/testthat/test_webmocks/data/cran_package_checks.html Illustrates a common warning during vignette re-building when Pandoc is not available, causing a fallback to R Markdown v1. This can lead to errors in processing vignettes, particularly those involving complex R code or specific package dependencies. ```r Warning in engine$weave(file, quiet = quiet, encoding = enc) : Pandoc (>= 1.12.3) not available. Falling back to R Markdown v1. ``` -------------------------------- ### Error Handling in Assessment and Scoring Source: https://context7.com/pharmar/riskmetric/llms.txt Illustrates the use of assessment and scoring error handlers. Provides three score-level handlers: `score_error_default`, `score_error_zero`, and `score_error_NA`. The `assessment_error_empty` handler stores an empty `pkg_metric_error` object. ```r library(riskmetric) ``` -------------------------------- ### Inspecting Errored Metrics Source: https://context7.com/pharmar/riskmetric/llms.txt This code snippet demonstrates how to identify and inspect metrics that resulted in an error during assessment. It filters the assessed metrics to find those inheriting from `pkg_metric_error`. ```R assessed <- pkg_ref("dplyr") %>% pkg_assess() errors <- Filter(function(m) inherits(m, "pkg_metric_error"), assessed) names(errors) # e.g., "covr_coverage" if covr is not available ``` -------------------------------- ### Summarize Scores with Default and Custom Weights Source: https://context7.com/pharmar/riskmetric/llms.txt Aggregates per-metric scores into a composite risk value. Accepts an optional weights vector to emphasize specific metrics. Requires the 'riskmetric' and 'dplyr' libraries. ```r library(riskmetric) library(dplyr) scored <- pkg_ref(c("riskmetric", "dplyr")) %>% pkg_assess() %>% pkg_score() # Default equal weighting (already called by pkg_score, shown explicitly here) summarize_scores(scored) # [1] 0.312 0.089 # Custom weights emphasizing downloads and vignettes custom_weights <- c( downloads_1yr = 3, has_vignettes = 2, has_news = 1, has_maintainer = 1, has_source_control = 1 ) summarize_scores(scored, weights = custom_weights) ``` -------------------------------- ### pkg_score() — Score Package Assessments Source: https://context7.com/pharmar/riskmetric/llms.txt This function converts `pkg_metric` columns in an assessed tibble or `list_of_pkg_metric` into numeric scores between 0 and 1. It then computes a composite `pkg_score` column using `summarize_scores()`. Lower scores indicate lower risk. Each metric has its own `metric_score.*` S3 method for scoring. ```APIDOC ## pkg_score() — Score Package Assessments ### Description Converts `pkg_metric` columns in an assessed tibble (or `list_of_pkg_metric`) into numeric scores between 0 and 1, then computes a composite `pkg_score` column via `summarize_scores()`. Lower scores mean lower risk. Each metric has its own `metric_score.*` S3 method that implements the scoring formula. ### Usage ```r library(riskmetric) library(dplyr) # Full pipeline: reference → assess → score result <- pkg_ref(c("riskmetric", "dplyr", "Rcpp")) %>% pkg_assess() %>% pkg_score() # View composite risk scores result %>% select(package, version, pkg_score) # # A tibble: 3 × 3 # package version pkg_score # riskmetric 0.2.6 0.312 # dplyr 1.1.4 0.089 # Rcpp 1.0.12 0.041 # Score with custom error handling (NA instead of 0 for failed metrics) result_na <- pkg_ref("newpkg") %>% pkg_assess() %>% pkg_score(error_handler = score_error_NA) # Score a single pkg_metric object metric_score(assess_has_news(pkg_ref("riskmetric"))) # [1] 1 ``` ``` -------------------------------- ### Error Handling Functions Source: https://context7.com/pharmar/riskmetric/llms.txt Error handlers control how assessment and scoring failures are recorded. Functions like `score_error_default`, `score_error_zero`, `score_error_NA`, and `assessment_error_empty` manage error recording during the risk assessment pipeline. ```APIDOC ## Error Handling ### Description Assessment and scoring error handlers control how failures are recorded. Three score-level handlers are provided: `score_error_default` (warns and returns 0), `score_error_zero` (silently returns 0), and `score_error_NA` (silently returns `NA`). The `assessment_error_empty` handler stores an empty `pkg_metric_error` object so the pipeline can continue. ### Usage ```r score_error_default(e) score_error_zero(e) score_error_NA(e) assessment_error_empty(e) ``` ### Parameters * `e`: The error object encountered during assessment or scoring. ### Request Example ```r library(riskmetric) # Example usage within a pipeline (conceptual) # result <- pkg_ref("some_package") %>% # pkg_assess(error_handler = assessment_error_empty) %>% # pkg_score(error_handler = score_error_default) ``` ### Response These functions modify how errors are handled and recorded within the riskmetric pipeline. They do not return a direct value but influence the pipeline's behavior upon encountering errors. ``` -------------------------------- ### Vignette Processing Error (R Markdown) Source: https://github.com/pharmar/riskmetric/blob/master/tests/testthat/test_webmocks/data/cran_package_checks.html Highlights an error during vignette processing, specifically 'processing vignette 'Coxnet.Rmd' failed with diagnostics: NA/NaN/Inf in foreign function call (arg 19)'. This indicates a failure within the underlying R code executed by the vignette. ```r Error: processing vignette 'Coxnet.Rmd' failed with diagnostics: NA/NaN/Inf in foreign function call (arg 19) ``` -------------------------------- ### Vignette Processing Error (R Markdown Family) Source: https://github.com/pharmar/riskmetric/blob/master/tests/testthat/test_webmocks/data/cran_package_checks.html Shows an error during the processing of 'glmnetFamily.Rmd', indicating 'NA/NaN/Inf in foreign function call (arg 25)'. This error suggests a problem within the R code execution for this specific vignette. ```r Error: processing vignette 'glmnetFamily.Rmd' failed with diagnostics: NA/NaN/Inf in foreign function call (arg 25) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.