First, some motivation. Here are two equivalent blocks of code:
Which you would have recognized written like this:
One is pretty easy to read, the other is horrendous. The two style guides you should use in your R code are:
variable.name (Google preferred)variableName (Google accepted)VariableName (Google accepted)variable_name (Tidyverse)In choosing names, be sure that the names you choose have meaning.
Bad:
Good:
R doesn’t care about spaces or newlines in your code. Use this to write beautiful code!
Compare:
To:
Note the use of: