Use the tidyverse-style function template
Source:R/use_function_template.R
use_function_template.RdCreates a new R file based on the comprehensive function template that includes best practices from the tidyverse style guide and design guide. The template covers argument ordering, validation, error handling, dots usage, and documentation patterns that are not automatically checked by lintr/styler.
Usage
use_function_template(name, open = interactive())Details
The template includes:
Roxygen2 documentation with best practices
Argument ordering checklist (data → descriptors → ... → details)
Multiple validation options (stopifnot, cli, rlang, checkmate)
Dots handling patterns
NULL pattern for optional arguments
Side-effect functions pattern
Options object pattern
Error constructor pattern
Comprehensive design principles checklist
After creating the file, delete sections you don't need and customize the function to your requirements.