开发者

What's a good example of really clean and clear [R] code, for pedagogical purposes? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 8 years ago.

Improve this question

I'm working with a small team of analysts and statisticians on what will be a medium-sized body of R code. They're smart people, but they're not trained or experienced as programmers, per se. (I am.) They'v开发者_运维问答e written some R code, but for our project to be expandable, efficient, and maintainable, it needs to become well-structured, and rather more piratical. One of the better way to learn to be a better programmer is to study elegant existing code. Can anyone suggest some open source examples of R code (on CRAN or wherever) that you think are particularly clear, literate, and good examples? Functional is good, S3 objects are OK, deep magic is bad.


My two favorite packages can both be browsed on R-Forge and are very well documented (although they may be too big for an introduction):

  • The caret homepage and source code.
  • The zelig homepage and and source code.

I think that the Google style guide does a great job of capturing the style of the Core team, although Hadley has his own style guide which can be read if you're looking at his packages. You can browse Hadley's packages on Github (and his homepage is full of useful content), in particular:

  • plyr
  • ggplot2
  • reshape

This article on the R-Wiki is also a good read for seeing ways to optimize code.


Not strictly related, but make sure you get them used to using Source Control (perforce, subversion, git, rcs, etc) as quickly as possible. That reduces the learning pains.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜