This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
development:ohdsi_code_style_for_r [2017/06/09 18:45] chrisknoll |
development:ohdsi_code_style_for_r [2018/11/13 07:57] schuemie [Indentation] |
||
---|---|---|---|
Line 92: | Line 92: | ||
<code> | <code> | ||
if (y < 0 && debug) { | if (y < 0 && debug) { | ||
- | message("Y is negative") Line length | + | message("Y is negative") |
} | } | ||
</code> | </code> | ||
Line 153: | Line 153: | ||
''# Plot data ---------------------------'' | ''# Plot data ---------------------------'' | ||
+ | |||
+ | ===== Curly brackets and new line ===== | ||
+ | Opening curly brackets should precede a new line. A closing curly bracket should be followed by a new line except when it is followed by ''else'' or a closing parenthesis. | ||
+ | |||
+ | **Good** | ||
+ | <code> | ||
+ | if (a == b) { | ||
+ | doSomething() | ||
+ | } else { | ||
+ | doSomethingElse() | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | **Bad** | ||
+ | <code> | ||
+ | if (a == b) | ||
+ | { | ||
+ | doSomething() | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | doSomethingElse() | ||
+ | } | ||
+ | </code> | ||
+ |