Advertisement · 728 × 90
#
Hashtag
#roxygen2
Advertisement · 728 × 90
Cross-references: 🔗

#' @seealso [other_function()], [pkg::function()]
#' @family utility functions
#' @inheritParams parent_function

Cross-references: 🔗 #' @seealso [other_function()], [pkg::function()] #' @family utility functions #' @inheritParams parent_function

Advanced tags: ⚡

#' @section Warning:
#' This function modifies data in place.
#' 
#' `r paste("Generated on", Sys.Date())` # Run R code

Advanced tags: ⚡ #' @section Warning: #' This function modifies data in place. #' #' `r paste("Generated on", Sys.Date())` # Run R code

Post image

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

#rstats #roxygen2 #Documentation #RPackageAdvent2025

11 0 1 1
Screenshot showing the @examplesTempdir feature for R packages. The image compares two approaches for managing temporary directories in package examples. The traditional method requires multiple lines of code with setwd(tempdir()) and cleanup commands. With the {rocleteer} package, this can be simplified to a single @examplesTempdir tag. The image shows code examples of both approaches, highlighting how the new method reduces boilerplate code.

Old approach:

#' @examples
#' \dontshow{.old_wd <- setwd(tempdir())}
#'
#' # Your code here
#'
#' \dontshow{setwd(.old_wd)}

New approach:

#' @examplesTempdir
#' # Your code here

Screenshot showing the @examplesTempdir feature for R packages. The image compares two approaches for managing temporary directories in package examples. The traditional method requires multiple lines of code with setwd(tempdir()) and cleanup commands. With the {rocleteer} package, this can be simplified to a single @examplesTempdir tag. The image shows code examples of both approaches, highlighting how the new method reduces boilerplate code. Old approach: #' @examples #' \dontshow{.old_wd <- setwd(tempdir())} #' #' # Your code here #' #' \dontshow{setwd(.old_wd)} New approach: #' @examplesTempdir #' # Your code here

Tired of writing tempdir()/tempfile() code in your #rstats package examples to be compliant with CRAN's file policy?

Get CRAN-compliant file examples with a single #roxygen2 tag: examplesTempdir.

📝 Read more: blog.thecoatlessprofessor.com/programming/...

6 0 0 0