User Tools

Site Tools


development:ohdsi_code_style_for_r

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
development:ohdsi_code_style_for_r [2017/06/09 17:34]
chrisknoll
development:ohdsi_code_style_for_r [2018/02/18 15:37]
schuemie
Line 44: Line 44:
 <​code>​ <​code>​
 if (debug) { if (debug) {
-  do(x);+  do(x)
 } }
  
-plot(x, y);+plot(x, y)
 </​code>​ </​code>​
  
Line 54: Line 54:
 <​code>​ <​code>​
 if(debug){ if(debug){
-  do(x);+  do(x)
 } }
  
-plot (x, y);+plot (x, y)
 </​code>​ </​code>​
  
Line 68: Line 68:
 <​code>​ <​code>​
 if (debug) { if (debug) {
-  do(x);+  do(x)
 } }
  
-diamonds[5, ];+diamonds[5, ]
 </​code>​ </​code>​
  
Line 77: Line 77:
 <​code>​ <​code>​
 if ( debug ) {  # No spaces around debug if ( debug ) {  # No spaces around debug
-  do(x);+  do(x)
 } }
  
-x[1,]  # Needs a space after the comma +x[1,]   # Needs a space after the comma 
-x[1 ,] # Space goes after comma not beforeCurly braces+x[1 ,]  # Space goes after comma not beforeCurly braces
 </​code>​ </​code>​
  
Line 122: Line 122:
 <​code>​ <​code>​
 if (a == b) { if (a == b) {
-  doSomething();+  doSomething()
 } }
 </​code>​ </​code>​
Line 129: Line 129:
  
 <​code>​ <​code>​
-if (a == b) doSomething();+if (a == b) doSomething()
 </​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>​
 +
development/ohdsi_code_style_for_r.txt · Last modified: 2020/04/06 13:39 by schuemie