-
Notifications
You must be signed in to change notification settings - Fork 43
R guidelines
mdijkstra edited this page Sep 30, 2014
·
13 revisions
- Please make use of our template for R-scripts
- No magic in scripts. Use parameter file + command line parameters to indicate file names. Do not manipulate file names in scripts.
- Avoid the use of global variables from within functions (e.g. with
<<-
) - Functions should have only one task
- Use tabs for indentation, not spaces
- Use
=
for assignments, not<-
. This choice is arbitrary (opinions are divided). - If main code is in
main.R
, put its functions inmain_functions.R
- R-scripts are ignorant of their location. Here we explain how to
source(main_functions.R)
- Please note our guidelines for documentation and tests
- Always use
<
(smaller than) or<=
, never>
or>=
- Always put constants first, e.g.
if (1 == my.variable) …
- See also Google's R-style guide
- E.g.
FunctionName
(we allowfunctionName
andfunction.name
too),file_name.R
,variable.name
- E.g.