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: https://roxygen2.r-lib.org

#rstats #roxygen2 #Documentation #RPackageAdvent2025

Experimenting with `@examplesWebR` - a new #roxygen2 tag that makes #rstats package examples interactive!

Instead of static code blocks, users get "View in webR REPL" buttons that open examples in their browser or the embedded webR REPL. No R installation needed!

Still WIP (🚧 ) since the main challenge is distributing dev packages for #webR (non-CRAN versions).

Would love input on the best approach! Here or:

https://github.com/coatless-rpkg/rocleteer/pull/1

Dear #rstats friends, remember all those tempdir()/tempfile() gymnastics for CRAN compliance?

examplesTempdir just made that circus act a one-liner with a simple #roxygen2 tag extension. Your future self will thank you.

💻 Code: https://github.com/coatless-rpkg/rocleteer

📝 Post: https://blog.thecoatlessprofessor.com/programming/r/simplifying-file-based-examples-with-atexamplestempdir-in-r-packages/

GitHub - coatless-rpkg/rocleteer: Custom roclets and tags for roxygen2

Custom roclets and tags for roxygen2. Contribute to coatless-rpkg/rocleteer development by creating an account on GitHub.

GitHub

TIL you can include multiple `#' @examples` and `#' @examplesIf` statements in your #roxygen2 #RStats code for conditional examples based on the user's system state.

I had previously thought that you could only use `#' @examples` OR `#' @examplesIf`, but never both. This is fantastic news!

https://github.com/cran/report/blob/ee8409bb541f7289154b16ca724ed2a3923eb660/R/report_info.R#L13-L34

report/R/report_info.R at ee8409bb541f7289154b16ca724ed2a3923eb660 · cran/report

:exclamation: This is a read-only mirror of the CRAN R package repository. report — Automated Reporting of Results and Statistical Models. Homepage: https://easystats.github.io/report/ Report bug...

GitHub

That was new. Mistakenly put a new function definition below an #RStats #ROxygen2 stub for exporting a method, and my NAMESPACE got very, very weird with stuff from the function description.

But faults on me for not looking at the NAMESPACE changes before committing and pushing the result.

Thankfully simple to fix. Move the function definition, delete the borked NAMESPACE, and {devtools::document()} to refresh it. Examine it, commit, push.

@beps I truly understand what you mean. I am now talking a little about #RKWard. We have a solid integration of #git, #rio and some other tools. #quarto works. A tight integration of #styler would be nice. We have a good R console and a terminal. Likewise, we don't have the deep integration of #devtools, #roxygen2 and #pkgdown. Some find it good (I) others find it a hindrance.
In the end, there are many good choices.

#rstats

The {document} #rstats 📦 creates roxygen2-style documentation for functions that aren't (yet) part of an R package.

In the screenshot below, top left shows a test.R file with a function called test_function , including roxygen definitions. After running

d <- document("test.R")

I can use

?test_function

to read the help file as if it were part of a package.

By Andreas Dominik Cullmann

https://cran.r-project.org/web/packages/document/vignettes/Introduction_to_document.html

@rstats
#roxygen #roxygen2

An Introduction to document

Hey, #rstats pkg devs, we are trying #cpp11, and it seems that #roxygen2 tags won't work like they do with #Rcpp. Is this a thing? cc @Emil_Hvitfeldt