R 中的编码原则 - 寻找在 R 中编写复杂程序的书籍/网络教程

发布于 2024-12-29 11:25:20 字数 1539 浏览 3 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

番薯 2025-01-05 11:25:20

更新:

在编写软件包时,您肯定需要查看两本最新的书籍:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文