rlang

repository·main·Indexed 20 days ago

https://github.com/r-lib/rlang

A collection of frameworks and APIs for advanced programming with R. rlang provides the core infrastructure for data-masking (tidy eval), structured error handling, argument validation, and low-level manipulation of R objects such as environments, calls, and symbols. It serves as the foundation for many tidyverse packages, including dplyr and ggplot2.

Tokens
6.6K
Snippets
24
Records
37
Agent score
69%

What's inside rlang

  1. What is rlang?

    main
    rlang is a collection of frameworks and APIs designed for advanced programming with R. It provides core infrastructure for data-masking, error handling, argument validation, and low-level manipulation of R objects like environments, calls, and symbols.
  2. Review reverse dependency (revdep) check results

    main

    The revdep directory contains reports on reverse dependency checks. These reports identify packages that may break when rlang is updated.

    • Failed to check: Lists packages where the reverse dependency check could not be completed (indicated by an error code in the error column).
    • New problems: Lists specific packages that have recently introduced new errors or warnings in their reverse dependency checks. These often include links to detailed problem descriptions in problems.md.
  3. How tidy eval works in rlang

    main

    tidy eval is a programmable data-masking framework used extensively in the tidyverse (e.g., dplyr, ggplot2). It allows users to pass unquoted expressions to functions.

    Key components include:

    • The embracing operator {{ }}.
    • Name injection using glue operators: "{" and "{{" .
    • Support for dynamic dots via list2(), which can be spliced using the !!! operator.
  4. How rlang errors work

    main

    rlang errors provides tools for signaling and displaying structured errors.

    Key features include:

    • Error Creation: Use abort() to create errors that support bullet lists, structured metadata, and error chaining.
    • Backtrace Capture: Use global_entrance() to capture backtraces.
    • Error Display: Use last_error() and last_warnings() to display errors. The display is optimized for bullet lists and chained errors and can optionally integrate with the cli package via local_use_cli().
  5. Use rlang for argument intake and validation

    main

    rlang provides tools to check, validate, and preprocess function arguments and dots.

    Argument Checking:

    • arg_match()
    • check_required()
    • check_exclusive()

    Dots Checking:

    • check_dots_used()
    • check_dots_empty()

    Dynamic Dots:

    • list2(): Collects dots into a list. These dots support splicing with !!! and name injection with glue operators ("{" and "{{" ).
  6. Install rlang

    main

    You can install the released version of rlang from CRAN or the development version from GitHub.

    CRAN (Released version):

    install.packages("rlang")

    GitHub (Development version): Requires the pak package.

    # install.packages("pak")
    pak::pkg_install("r-lib/rlang")
    install.packages("rlang")
  7. Get detailed dependency information using revdepcheck::cloud_details()

    main

    When investigating issues with specific packages (such as bridgr, meta, plotly, or rollama) identified in reverse dependency checks, you can retrieve more detailed information by calling revdepcheck::cloud_details() and passing the package name as the second argument.

    revdepcheck::cloud_details(, "bridgr")
  8. Bypass suggested package checks during R package checking

    main

    When running R package checks (e.g., via R CMD check), the process may fail if certain suggested packages are missing. You can attempt to proceed with the check without these suggested packages by setting the environment variable _R_CHECK_FORCE_SUGGESTS_ to false.

    export _R_CHECK_FORCE_SUGGESTS_=false
  9. Troubleshoot 'Packages suggested but not available' errors

    main

    If you encounter an error stating Packages suggested but not available: <package_list>, the R check is failing because it expects suggested packages to be present for a complete check.

    To resolve this, you can:

    1. Install the missing suggested packages.
    2. Or, bypass the requirement by setting the environment variable _R_CHECK_FORCE_SUGGESTS_ to false.
  10. Troubleshoot missing dependencies in MixMashNet

    main

    The MixMashNet package (version 1.1.0) fails installation because a required dependency is missing. To resolve the ERROR during the dependency check, install:

    • EGAnet
    Package required but not available: ‘EGAnet’
  11. Troubleshoot 'Vignette re-building failed' errors

    main

    If a package check fails with the error Error: Vignette re-building failed, it means the R Markdown (.Rmd) files used for documentation could not be processed.

    Common symptoms include:

    • SUMMARY: processing the following files failed: ‘<file_name>.Rmd’
    • Execution halted

    This usually stems from code errors within the vignette files themselves or missing dependencies required specifically for the vignette execution environment.

  12. Troubleshoot missing package dependencies

    main

    R package checks may fail with an ERROR during the dependency check phase if a required package listed in the DESCRIPTION file is not available in the current environment.

    Common error patterns include:

    • Package required but not available: ‘<package_name>’ (e.g., clusterProfiler or semPlot).

    To resolve this, ensure that all dependencies listed in the package's DESCRIPTION file are installed in your R library.

    Package required but not available: ‘clusterProfiler’