11.6 Resources

This section provides links to resources related to functions and writing functions.

11.6.1 More about functions

For more details on R functions:

Summary on functions from the [RStudio cheatsheet](https://www.rstudio.com/resources/cheatsheets/) on **Advanced R**.

Figure 11.3: Summary on functions from the RStudio cheatsheet on Advanced R.

11.6.2 Programming

There are many good books on computer programming, but even more bad books on the same topic, unfortunately. Here are some recommendations that I found helpful.

Advanced R

To really understand how functions are evaluated and used in R, Advanced R (Wickham, 2014a) devotes chapters on

See also the 2nd edition of Advanced R (Wickham, 2019a).

For specific issues when writing functions within the tidyverse, see:


To discover programming as an inspiring and deeply gratifying intellectual endeavor, it helps to stay away from the “Mastering WhizzBang v2.0 in 10 easy steps” and “X for dummies” variety of flashy cookbooks and stick with the serious stuff:

  • Although Donald E. Knuth published the first volume of The Art of Computer Programming (TAOCP) in 1968, it is still incomplete today (Knuth, 1968).59 The volumes provide the defining treatise on the design and analysis of algorithms and evoke either reverence or fear in the initiated (i.e., a bit like The Bible):

  • A classic text on object-oriented programming with a mindset of combining simple functions into powerful systems is The Structure and Interpretation of Computer Programs (SICP) (Abelson, Sussman, & Sussman, 1996):60

  • For developing a pragmatic approach towards programming and software design, The Pragmatic Programmer: From Journeyman to Master (Hunt & Thomas, 1999) is helpful, despite its cringeworthy title.

Online help

Teach a man to fish, and he’ll use StackOverflow for a day.
Give him a fish, and he’ll use StackOverflow for a lifetime of free fish.

Joshua Ulrich (2016)

R developers devote an enormous amounts of time and effort into documenting functions and packages. If your questions are not answered by typing ‘?’ and the name of a function, here are some pointers to online resources:

  • R help shows that R provides many ways of helping yourself, but also pointers to various online resources

  • R seek is a search engine specializing on R

  • rdrr.io allows searching R packages

  • Stack Overflow is a wonderful place to learn more about R — but make sure you properly searched previous answers prior to asking new questions


[11_functions.Rmd updated on 2020-10-30 16:01:15 by hn.]


Abelson, H., Sussman, G. J., & Sussman, J. (1996). Structure and interpretation of computer programs (2nd ed.). Retrieved from https://mitpress.mit.edu/sites/default/files/sicp/

Hunt, A., & Thomas, D. (1999). The pragmatic programmer: From journeyman to master. Addison-Wesley.

Knuth, D. E. (1968). The art of computer programming: Fundamental algorithms (Vol. 1). Retrieved from https://cs.stanford.edu/~knuth/taocp.html

Wickham, H. (2014a). Advanced R (1st ed.). Retrieved from http://adv-r.had.co.nz/

Wickham, H. (2019a). Advanced R (2nd ed.). Retrieved from https://adv-r.hadley.nz/

Wickham, H., & Grolemund, G. (2017). R for data science: Import, tidy, transform, visualize, and model data. Retrieved from http://r4ds.had.co.nz

  1. Fun fact: One of the collateral projects of TAOCP that pre-occupied the author for years was the development of a typesetting system that was able to present mathematical expressions and computer code in aesthetically pleasing form. This side-project developed into the TeX system (see Wikipedia: TeX/LaTeX for details), which is still the de facto standard in many sciences today.

  2. This book is originally from 1984 and uses the Lisp dialect Scheme. If this seems obscure, note that SICP is widely known as “the wizard book” or “the purple book”, and was used to teach many generations of MIT students into the realms of computer science.