Skip to content

Commit 3e2e4a5

Browse files
authored
Merge pull request ktaranov#6 from eshcherbakova/patch-3
Update R style guide and name convention.md
2 parents cf8b89f + 76d9110 commit 3e2e4a5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

R style guide and name convention.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Don't use underscores ( _ ) or hyphens ( - ) in identifiers. Identifiers should
3434
**BAD:** calculate_avg_clicks , calculateAvgClicks
3535

3636
Make function names verbs.
37+
3738
*Exception: When creating a classed object, the function name (constructor) and class should match (e.g., lm).*
3839
- kConstantName
3940

@@ -46,11 +47,13 @@ The maximum line length is 80 characters.
4647
### Indentation
4748

4849
When indenting your code, use two spaces. Never use tabs or mix tabs and spaces.
50+
4951
*Exception: When a line break occurs inside parentheses, align the wrapped line with the first character inside the parenthesis.*
5052

5153
### Spacing
5254

5355
Place spaces around all binary operators (=, +, -, <-, etc.).
56+
5457
*Exception: Spaces around ='s are optional when passing parameters in a function call.*
5558

5659
Do not place a space before a comma, but always place one after a comma.
@@ -90,6 +93,7 @@ plot (x = x.coord,
9093
main = (paste(metric, " for 3 samples ", sep = "")))
9194
```
9295
Do not place spaces around code in parentheses or square brackets.
96+
9397
*Exception: Always place a space after a comma.*
9498

9599
**GOOD:**
@@ -105,6 +109,7 @@ x[1,] # Needs a space after the comma
105109
### Curly Braces
106110

107111
An opening curly brace should never go on its own line; a closing curly brace should always go on its own 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.
112+
108113
**GOOD:**
109114
```
110115
if (is.null(ylim)) {
@@ -125,6 +130,7 @@ if (is.null(ylim)) {ylim <- c(0, 0.06)}
125130
Surround "else" with braces.
126131

127132
An "else" statement should always be surrounded on the same line by curly braces.
133+
128134
**GOOD:**
129135
```
130136
if (condition) {
@@ -197,6 +203,7 @@ hist(df$pct.spent,
197203
Function definitions should first list arguments without default values, followed by those with default values.
198204

199205
In both function definitions and function calls, multiple arguments per line are allowed; line breaks are only allowed between assignments.
206+
200207
**GOOD:**
201208
```
202209
PredictCTR <- function(query, property, numDays,

0 commit comments

Comments
 (0)