Please see also CodingForTor/CodingInC and CodingForTor/LoggingAndDocumentation because it is best to follow the guidelines there that may apply to R as well as c.
In addition please:
- end files with a newline
- use a maximum of 74 character per line
- use two spaces for indentation, four for following lines, no tabs
- use no trailing whitespace
You may find the following helpful to place in your .emacs This is derived from https://cran.r-project.org/doc/manuals/R-ints.html#R-coding-standards
Note that I would love to not make it indent so far for continued expressions, but I don't know how to do this. I have read through the elisp for emacs ess mode, but as far as I can tell the indent functions would have to be rewritten to support this.
(add-hook 'ess-mode-hook
(lambda ()
(setq 'c-basic-offset 4)
(setq 'c-default-style 'bsd)
(ess-set-style 'C++ 'quiet)
(font-lock-mode 1)
(setq 'show-trailing-whitespace t)
(setq 'ess-tab-always-indent t)
(setq ess-nuke-trailing-whitespace-p t)
)
)