home.social

#rpackageadvent2025 — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #rpackageadvent2025, aggregated by home.social.

fetched live
  1. We Made It! 🎉

    25 days. Complete modern R package development workflow. From usethis automation to CRAN submission. You have everything you need!

    Your Next Steps:
    ✨ Apply these tools to your packages
    📚 Bookmark for reference
    🤝 Share knowledge with community
    🚀 Build amazing R packages

    Thank you for following ! Now go make the R ecosystem better! 🎄📦
    Keep Learning: r-pkgs.org | usethis.r-lib.org

  2. Day 25: CRAN Submission Checklist and cran-comments.md

    Final steps for successful CRAN submission.

    Pre-submission checklist:

    - devtools::check() passes with 0 errors, warnings, notes
    - Test on multiple platforms (rhub, GitHub Actions)
    - Update NEWS.md and version number
    - Check reverse dependencies
    - Spell check documentation

  3. Day 24: rlang - Tidy Evaluation in Packages

    Handle user expressions safely in package functions.

    Basic tidy evaluation:
    my_summarise <- function(data, ...) {
    data |>
    dplyr::summarise(...)
    }

    # Embrace operator
    my_mutate <- function(data, col, value) {
    data |>
    dplyr::mutate({{ col }} := value)
    }

    Pro Tip: Use {{ }} (embrace) for single arguments, ... for multiple arguments.
    Resources: rlang.r-lib.org

  4. Day 23: cli - Beautiful Command Line Interfaces

    Create user-friendly messages and progress indicators.

    Enhanced messages:
    cli::cli_alert_success("Package built successfully!")
    cli::cli_alert_warning("Missing documentation for {.fn my_function}")
    cli::cli_abort("Invalid input: {.val {invalid_value}}")

    Pro Tip: Use semantic markup like {.fn function_name} and {.val value} for consistent formatting.
    Resources: cli.r-lib.org

  5. Day 22: S3, S4, and S7 Object Systems

    Create robust object-oriented interfaces with R's object systems.

    Pro Tip: Use S3 for simple classes, S4 for complex validation, S7 for modern OOP.
    Resources: rconsortium.github.io/S7

  6. Day 21: rhub - Multi-Platform Testing

    Test your package on multiple platforms before CRAN submission.

    Resources: r-hub.github.io/rhub/

    1/ CRAN Tests Everywhere: Windows, macOS, Linux, multiple flavors. Your package must work on all. rhub lets you test before submission.

    2/ Run CRAN Checks:
    rhub::check_for_cran()

    Tests on Debian, Windows, Fedora. Same platforms CRAN uses. Catch platform-specific issues early.

  7. Day 20: Performance Testing with bench

    Profile and benchmark your package functions.

    Basic benchmarking:

    results <- bench::mark(
    old_approach = old_function(data),
    new_approach = new_function(data),
    check = FALSE, # Skip result equality check
    iterations = 100
    )
    plot(results)

    Pro Tip: Include benchmarks in your test suite to catch performance regressions.
    Resources: bench.r-lib.org/

  8. Day 19: goodpractice - Package Health Checks

    Get comprehensive feedback on package quality.

    Usage:
    goodpractice::gp()

    Checks include:
    ⬩ Function length and complexity
    ⬩ Namespace usage
    ⬩ DESCRIPTION completeness
    ⬩ Code coverage
    ⬩ R CMD check results

    Pro Tip: Run gp() before CRAN submission to catch common issues early.
    Resources: github.com/mangothecat/goodpractice

  9. Day 18: Use linters!

    Maintain consistent, readable code style automatically.

    Setup:
    # .lintr file in project root
    linters: linters_with_defaults(
    line_length_linter(120),
    commented_code_linter = NULL
    )

    Usage:
    lintr::lint_package()
    styler::style_pkg()

    Pro Tip: Add both to pre-commit hooks for automatic code formatting.
    Resources: lintr.r-lib.org/

  10. Day 17: vcr - Recording API Calls for Tests

    Record real API responses for reliable, fast tests without hitting live APIs.

    Setup:
    library(vcr)
    vcr_configure(dir = "tests/fixtures/vcr_cassettes")

    Pro Tip: Commit cassette files to git for reproducible tests across environments.
    Resources: docs.ropensci.org/vcr

  11. Day 16: Testing with Mocks using testthat
    Test functions that depend on external resources using testthat's built-in mocking.

    Pro Tip: Use local_mocked_bindings() to mock functions within the test scope only.
    Resources: testthat.r-lib.org

  12. Day 15: Snapshot Testing with testthat

    Test complex outputs that are hard to specify exactly.

    Text snapshots:
    test_that("error messages are informative", {
    expect_snapshot(my_function(bad_input), error = TRUE)
    })

    Pro Tip: Review snapshot changes carefully - they capture everything, including whitespace and formatting.

  13. Day 14: testthat 3rd Edition Features
    Modern testing with the latest testthat features.

    Setup:
    usethis::use_testthat(3)

    New features:

    # Snapshot tests
    test_that("plot output is stable", {
    p <- my_plot(data)
    vdiffr::expect_doppelganger("basic-plot", p)
    })

    Helper functions in tests/testthat/helper.R

    Pro Tip: Use test_that() with descriptive names that explain what should happen.
    Resources: testthat.r-lib.org

  14. Day 13: covr - Test Coverage Reporting

    Track how much of your code is tested.
    use for code you don't want to cover (like basic R functions etc)

    Basic usage:
    covr::package_coverage()
    covr::report()

    Integration with CI:
    usethis::use_github_action("test-coverage")
    usethis::use_coverage() # Adds codecov badge

    Pro Tip: Aim for >80% coverage, but focus on testing critical functions thoroughly rather than chasing 100%.
    Resources: covr.r-lib.org

  15. Day 12: README.Rmd Automation

    Create dynamic READMEs that stay up-to-date with your code.

    Setup:
    usethis::use_readme_rmd()

    Include these sections:

    󠁯•󠁏󠁏 Installation instructions
    󠁯•󠁏󠁏 Basic usage example
    󠁯•󠁏󠁏 Lifecycle badges
    󠁯•󠁏󠁏 Build status badges

    Keep it fresh:

    # Add to .github/workflows/
    - name: Render README
    run: Rscript -e 'rmarkdown::render("README.Rmd")'

  16. Day 11: NEWS.md and Semantic Versioning
    Keep users informed about package changes.

    Create NEWS.md:
    usethis::use_news_md()

    Structure:
    # mypackage 1.2.0

    ## New features
    * Added `new_function()` for advanced analysis (#15)

    ## Bug fixes
    * Fixed issue with missing values in `existing_function()` (#12)

    Pro Tip: Follow semantic versioning: MAJOR.MINOR.PATCH for breaking.feature.bugfix changes.

  17. Day 10: lifecycle - Managing Function Deprecation

    Communicate changes to users gracefully with lifecycle badges.

    Setup:
    usethis::use_lifecycle()

    #' @lifecycle experimental
    new_function <- function() {
    # function body
    }

    Pro Tip: Use lifecycle stages: experimental → stable → superseded → deprecated.
    Resources: lifecycle.r-lib.org

  18. Day 9: Vignettes with knitr and rmarkdown

    Create comprehensive tutorials and examples for your package.

    Add a vignette:
    usethis::use_vignette("getting-started")

    Vignette best practices:

    ● Start with a clear problem statement
    ● Show realistic examples
    ● Keep computational time under 5 minutes
    ● Use pre-computed results for heavy computations

    Pro Tip: Use knitr::opts_chunk$set(collapse = TRUE, comment = "#>") for clean output.

  19. Day 8: pkgdown Customization and Deployment

    Transform your package documentation into a polished website.

    Advanced customization:

    # _pkgdown.yml
    template:
    params:
    bootswatch: flatly

    reference:
    - title: "Data manipulation"
    contents:
    - starts_with("mutate")
    - ends_with("_join")

    Auto-deployment:
    usethis::use_github_action("pkgdown")

    Pro Tip: Group functions logically in the reference section for better navigation.

  20. Day 7: roxygen2 Advanced Tags and Cross-References 📝

    Master documentation with advanced roxygen2 features, with markdown-style writing! 🎯

    💡 Pro Tip: Use @inheritDotParams to inherit ... parameter documentation.
    📚 Resources: roxygen2.r-lib.org

  21. The Bottom Line: Manually editing DESCRIPTION = typos, wrong formatting, forgotten versions. usethis = automatic, correct, sorted. Let the tool handle the details so you focus on code.
    Tomorrow: Advanced roxygen2 for better documentation! 📝

    Resources: usethis.r-lib.org

  22. Day 6/25: Adding dependencies to your package 🧵

    The Manual DESCRIPTION Problem: You need to add dplyr to your package. Open DESCRIPTION, find Imports, type "dplyr," hope you didn't typo it, wonder if you need a version constraint, forget to sort alphabetically. Then your package fails R CMD check.

    usethis Does It Right:
    usethis::use_package("dplyr")

    Adds to Imports section, alphabetically sorted, with correct formatting. One command, zero mistakes.

  23. Day 5: Package Structure with pkgdown Site Generation 🌐
    Create beautiful documentation websites for your packages! ✨

    Setup: 🔧

    usethis::use_pkgdown()
    pkgdown::build_site()

    💡 Pro Tip: Use usethis::use_pkgdown_github_pages() for automatic deployment.
    📚 Resources: pkgdown.r-lib.org

    📖

  24. Day 4: .Rbuildignore and .gitignore Best Practices 📁

    Control what gets included in your package build and git repository! 🎯

    💡 Pro Tip: Use usethis::use_build_ignore() to add entries programmatically.
    🗃️

  25. Day 3: GitHub Actions with r-lib/actions - CI/CD Setup 🚀

    Automate your package testing across multiple platforms and R versions! 🔄
    Quick setup: ⚡

    💡 Pro Tip: The standard check runs on Windows, macOS, and Ubuntu with
    multiple R versions.

    📚 Resources: github.com/r-lib/actions

  26. Day 2: devtools - Essential Development Workflow 🔧

    The devtools package streamlines your package development workflow with key functions! ⚡

    💡 Pro Tip: Use Ctrl/Cmd + Shift + L in RStudio to quickly run load_all().

    📚 Resources: devtools.r-lib.org


    🛠️

  27. Day 1: usethis - Project Setup Automation 🎯

    The usethis package is your best friend for automating repetitive package development tasks! 🤖

    💡 Pro Tip: Set up your global options once with usethis::edit_r_profile() to add your name, email, and preferred license.

    📚 Resources: usethis.r-lib.org
    📦

  28. How to Follow Along:

    I'll post daily starting Dec 1st
    Each post includes practical code examples
    Follow the hashtag
    Comment with your questions - I'll answer!
    Share your favorite tips with the community

    Why I'm Doing This: I've developed multiple R packages and learned these lessons the hard way. My goal is to save you time, frustration, and help you build better packages that users love.
    Ready to level up your R package game? See you December 1st! 🚀

  29. 🎄 ANNOUNCEMENT: R Package Development Advent Calendar 2025! 🎄

    Starting December 1st, I'm launching a 25-day journey through modern R package development. But this isn't just another tips series - here's why you should follow along 🧵

    The Problem: R package development can feel overwhelming. Between documentation, testing, CI/CD, and CRAN submission, there are dozens of tools to learn.