There are two more recent books that you definitely need to check out when writing packages:
Advanced R from Hadley Wickham, explaining about environments and other advanced topics.
R Packages from Hadley Wickham, giving a great guide for package writing
There isn't one book or style guide for writing R packages; there are numerous books about R that include package writing etc, and the R internals give you a style guide as well.
Both books give a lot of insight in R itself and contain useful style tips. Gentleman focuses on object oriented programming (as Bioconductor is largely S4 based), and Chambers is difficult to read but a rich information mine.
Next to that, you have a lot of information on stackoverflow to get ideas:
But basically you'll have to sit down with your team and agree on a standard. There's no 'best' way, so you all just have to agree on a good way you all use in order to keep the code consistent.
发布评论
评论(1)
更新:
在编写软件包时,您肯定需要查看两本最新的书籍:
Advanced R 来自 Hadley Wickham,解释了环境和其他高级主题。
Hadley Wickham 的 R Packages,为包编写提供了很好的指南
没有一本书或编写 R 包的风格指南;有许多关于 R 的书籍,包括包编写等,R 内部结构也为您提供了风格指南。
来自 R 内部的 R 编码标准
我认为包含有关 R 作为编程语言的最高级信息的书籍有以下两本:
生物信息学 R 编程,来自 Robert Gentleman
用于数据分析的软件:使用 R 进行编程,来自 John Chambers
这两本书都对 R 本身提供了很多见解,并包含有用的风格提示。 Gentleman 专注于面向对象编程(因为 Bioconductor 主要基于 S4),而 Chambers 很难阅读,但却是一个丰富的信息矿。
除此之外,您还可以在 stackoverflow 上获得大量信息来获取想法:
R 中的编码实践:不同风格的优点和缺点是什么?
R 中的函数注释约定
任何 R 风格指南/检查器?
您在 R 中命名变量的首选样式是什么?
常见 R 习语
但基本上,您必须与团队坐下来商定 标准。没有“最好”的方法,所以大家只需要就一种大家都使用的好方法达成一致,以保持代码的一致性。
UPDATE:
There are two more recent books that you definitely need to check out when writing packages:
Advanced R from Hadley Wickham, explaining about environments and other advanced topics.
R Packages from Hadley Wickham, giving a great guide for package writing
There isn't one book or style guide for writing R packages; there are numerous books about R that include package writing etc, and the R internals give you a style guide as well.
R coding standards from R internals
The books that contain the most advanced information about R as a programming language are in my view the following two:
R programming for bioinformatics from Robert Gentleman
Software for data analysis: Programming with R from John Chambers
Both books give a lot of insight in R itself and contain useful style tips. Gentleman focuses on object oriented programming (as Bioconductor is largely S4 based), and Chambers is difficult to read but a rich information mine.
Next to that, you have a lot of information on stackoverflow to get ideas:
Coding practice in R : what are the advantages and disadvantages of different styles?
Function commenting conventions in R
any R style guide / checker?
What is your preferred style for naming variables in R?
Common R idioms
But basically you'll have to sit down with your team and agree on a standard. There's no 'best' way, so you all just have to agree on a good way you all use in order to keep the code consistent.