Coding Standards for R

Roger D. Peng, Associate Professor of Biostatistics
Johns Hopkins Bloomberg School of Public Health

Coding Standards for R

  1. Always use text files / text editor

Coding Standards for R

  1. Always use text files / text editor

  2. Indent your code

Coding Standards for R

  1. Always use text files / text editor

  2. Indent your code

  3. Limit the width of your code (80 columns?)

Indenting

  • Indenting improves readability

  • Fixing line length (80 columns) prevents lots of nesting and very long functions

  • Suggested: Indents of 4 spaces at minimum; 8 spaces ideal

Coding Standards for R

  1. Always use text files / text editor

  2. Indent your code

  3. Limit the width of your code (80 columns?)

  4. Limit the length of individual functions