Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Clone this wiki locally
quanteda style guide
Style is important, and we want our code to be readable and look great.
In general, we follow the tidyverse style guide, with a few exceptions noted below.
- Source files use the extension .R (not .r).
- In general we have one function per .R file, although closely related functions (e.g. translation) are grouped in single .R files.
- Use meaningful lowercase names, in snake_case, for source files with words separated by underscores e.g.
Function and Variable names
snake_casefor function names and variable names, following the rOpenSci guidelines.
- Do not use dot.separated names for anything except when extending S3 generic methods.
- Use short variable names for very local or temporary variables, and longer explanatory names otherwise.
=, for assignment.
An opening curly brace should never go on its own line and should always be followed by a new line; a closing curly brace should always go on its own line, unless followed by else. Always indent the code inside the curly braces. See the examples in Hadley Wickham's book Advanced R.
In quanteda, we use 4 spaces (spaces, never tabs) for indentation. Why?
- It aids readability (and space is cheap!).
- It reminds us of Python.
- Mickey Mouse has four fingers, not two.
- Because otherwise you will be water-boarded.