Shared style guide
Resources¶
Resources for R:
Style¶
Line length¶
In most programming languages, keeping line length under 80 characters is a common best practice for readability and consistency. Note that Python usually sets the standard at 79 characters, while many modern languages allow up to 100.
It's helpful to add rulers to the editor. In VS Code, you can add the following to settings.json:
Indentation¶
| Language | Compile-sensitive? | Indent convention |
|---|---|---|
| R | 2 spaces | |
| Stata | 4 spaces | |
| Python | Yes | 4 spaces |
| MATLAB | 4 spaces | |
| Julia | 4 spaces | |
| SQL | 2 or 4 spaces | |
| LaTeX | 2 (esp. inside environments) or 4 spaces | |
| Markdown | Yes (lists, code) | 2 or 4 spaces |
| HTML | 2 or 4 spaces | |
| CSS | 2 spaces | |
| JavaScript | 2 or 4 spaces | |
| Bash | 2 spaces | |
| YAML | Yes | 2 spaces |
Markdown:
- TBD
\(\LaTeX\)
- Indentation doesn't matter for compilation.
- Overleaf uses 4 spaces for indentation by default. As of Aug 30, 2025, this setting can't be changed.
Comments¶
TBD
TBD
TBD
TBD
TBD
TBD
Section breaks¶
Trailing Newline¶
It is good practice to add a newline at the end of any text file, including scripts, to comply with POSIX standards and avoid issues in tools like Git.
Objects¶
Naming of objects¶
TBD
TBD
TBD
TBD
TBD
TBD
Data types¶
TBD
TBD
TBD
TBD
TBD
TBD
Functions¶
TBD
Placeholders¶
- Use plain
ALL_CAPSfor code objects (e.g.,DATASET,VARIABLE). - Use
"[ALL_CAPS]"for free-form text (e.g.,"[X_AXIS_LABEL]","[PLOT_TITLE]").
TBD
TBD
TBD
TBD
TBD
Programming¶
Modularization¶
TBD