7 R Code Style
This chapter has moved to Principles of Scientific Computing, the Morrison Lab’s general-purpose guide to coding for research projects: R Code Style (source: https://github.com/Morrison-Lab/psc).
That page covers:
- General Principles
- Clean Code Principles
- Function Structure and Documentation
- Assertions and Input Validation
- Avoiding Deep Nesting
- Prefer Existing Packaged Functions
- Prefer Per-Operation Grouping
- Avoid Hard-Coding Data with an External Source of Truth
- Construct Complex Inputs Before the Call
- Comments
- Line Breaks and Formatting
- Markdown and Quarto Formatting
- Messaging and User Communication
- Package Code Practices
- Tidyverse Replacements
- The here Package
- Object Naming
- Automated Tools for Style and Project Workflow
- Additional Resources
NoteLooking for a specific section that used to be here?
This chapter’s old section anchors still resolve on this page, so old bookmarks and links land here, but the content now lives on the page linked above, under the same anchor. For example, #sec-foo here is chapters/coding-style.html#sec-foo on the psc site.