R Package Development Best Practices
Instruction: Describe the best practices for developing and documenting an R package.
Context: This question evaluates the candidate's knowledge of the R package development process, including coding standards and documentation, crucial for creating reusable and maintainable code.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Start with a small public API and explicit input/output/error contracts. Use the standard package structure: DESCRIPTION for metadata/dependencies, NAMESPACE for exports/imports, R/ for code and man/ for help; add tests and vignettes as needed.
Use roxygen2 to generate documentation from maintained source comments, but review the generated help and rerun generation—co-location does not keep documentation correct automatically...