Skip to content

File, Class and Method Naming Conventions

Raphael Sonabend edited this page Jul 2, 2019 · 1 revision

Unlike other programming languages, the R community has not adopted strict naming conventions for files, classes and methods. Therefore we use our own, which come from a combination of Python and Java conventions. Any pull requests must adhere to these conventions.

For Files

Every R script should contain either one class (S3/S4/R6) or one function. This function can be a generic with multiple methods but should not be multiple functions. Similarly if the R script contains an R6 class then it should also contain all the private/public variables/methods.

Classes and Methods

  • ClassNames - UpperCamelCase: The first letter of every word is capitalised. All others are lower case.
  • publicMethods - lowerCamelCase: The first letter of every word, except the first, is capitalised. All others are lower case.
  • public_variables - lower_case: Every letter is lower case, words separated by underscores.
  • .privateMethods - .lowerCamelCase: Same as publicMethods but preceded with a period '.'
  • .private_variables - .lower_case: Same as private_variables but preceded with a period '.'

Exceptions to the rule: On occasion we will make exceptions to the rules above but these are at our discretion. Generally we will accept publicMethods to be given as all lower case if the words are abbreviations. For example we have stdev not stDev.

Clone this wiki locally