Syntax
Here, we learn about the general syntax in R, including assignment operators, curly braces and the else statement.
General Syntax
- For assignments, use
<-not=.
- Do not terminate your lines with semicolons
;or use semicolons to put more than one command on the same line. (Semicolons are not necessary, and are omitted for consistency with other Google style guides.)
Curly Braces
An opening curly brace should never go on its line; a closing curly brace should always go on its line.
- Always begin the body of a block on a new line.
You may omit curly braces when a block consists of a single statement; however, you must consistently either use or not use curly braces for single statement blocks.
Surround else with braces.
An else statement should always be surrounded on the same line by curly braces.