Skip to content

Coding conventions

Paige Miller edited this page Aug 6, 2018 · 7 revisions

This wasn't a page yet but it was listed on the Wiki home page.

Some coding conventions that we've discussed:

Use google's R style guide

When writing code, we usually strive for a set of coding syntax rules laid out by the R user community at Google. Syntax in the coding world means the spelling and grammar of a programming language. The guide was designed to make code easier to read, share, and verify. In the Data Management Section, we recommended also saving files according to the Google Style Guide.

In some circumstances, we've found that following the Google Style Guide is not practical or beneficial. For example, for variables, variable.name is preferred in google style but variableName is "accepted". However, sometimes parsing code from different sources leads to problems with the period case style but not the camelback case style. Many people in the lab also use camelcase to separate variables/data objects from functions which we often name with a verb (like "get") then an underscore and then the object of interest (like "stats"): get_stats. [other circumstances we've encountered?]

Code reviews

  • Have someone else review your code
  • Partner programming
  • If making HTML content, test it on multiple browsers before dissemination

Check how long different parts of your code take:

Lab Links

Clone this wiki locally