Coding practice in R : what are the advantages and disadvantages of different styles?

前端 未结 4 1597
一生所求
一生所求 2020-12-04 07:50

The recent questions regarding the use of require versus :: raised the question about which programming styles are used when programming in R, and what their advantages/disa

4条回答
  •  眼角桃花
    2020-12-04 08:18

    Naming conventions are extremely important for the readability of the code. Inspired by R's S4 internal style here is what I use:

    • camelCase for global functions and objects (like doSomething, getXyyy, upperLimit)
    • functions start with a verb
    • not exported and helper functions always start with "."
    • local variables and functions are all in small letters and in "_" syntax (do_something, get_xyyy), It makes it easy to distinguish local vs global and therefore leads to a cleaner code.

提交回复
热议问题