Statistical Science

Object-Oriented Programming, Functional Programming and R

John M. Chambers

Full-text: Open access


This paper reviews some programming techniques in R that have proved useful, particularly for substantial projects. These include several versions of object-oriented programming, used in a large number of R packages. The review tries to clarify the origins and ideas behind the various versions, each of which is valuable in the appropriate context.

R has also been strongly influenced by the ideas of functional programming and, in particular, by the desire to combine functional with object oriented programming.

To clarify how this particular mix of ideas has turned out in the current R language and supporting software, the paper will first review the basic ideas behind object-oriented and functional programming, and then examine the evolution of R with these ideas providing context.

Functional programming supports well-defined, defensible software giving reproducible results. Object-oriented programming is the mechanism par excellence for managing complexity while keeping things simple for the user. The two paradigms have been valuable in supporting major software for fitting models to data and numerous other statistical applications.

The paradigms have been adopted, and adapted, distinctively in R. Functional programming motivates much of R but R does not enforce the paradigm. Object-oriented programming from a functional perspective differs from that used in non-functional languages, a distinction that needs to be emphasized to avoid confusion.

R initially replicated the S language from Bell Labs, which in turn was strongly influenced by earlier program libraries. At each stage, new ideas have been added, but the previous software continues to show its influence in the design as well. Outlining the evolution will further clarify why we currently have this somewhat unusual combination of ideas.

Article information

Statist. Sci., Volume 29, Number 2 (2014), 167-180.

First available in Project Euclid: 18 August 2014

Permanent link to this document

Digital Object Identifier

Mathematical Reviews number (MathSciNet)

Zentralblatt MATH identifier

Programming languages functional programming object-oriented programming


Chambers, John M. Object-Oriented Programming, Functional Programming and R. Statist. Sci. 29 (2014), no. 2, 167--180. doi:10.1214/13-STS452.

Export citation


  • Becker, R. A. and Chambers, J. M. (1977). Gr-z: A system of graphical subroutines for data analysis. In Proc. Interface Symp. on Statistics and Computing 10 409–415.
  • Becker, R. A. and Chambers, J. M. (1984). S: An Interactive Environment for Data Analysis and Graphics. Wadsworth, Belmont, CA.
  • Becker, R. A. and Chambers, J. M. (1985). Extending the S System. Wadsworth, Belmont, CA.
  • Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988). The New S Language. Chapman & Hall, Boca Raton, FL.
  • Chambers, J. M. (1977). Computational Methods for Data Analysis. Wiley, New York.
  • Chambers, J. M. (1987). Interface for a quantitative programming environment. In Comp. Sci. and Stat., Proc. 19th Symp. on the Interface 280–286.
  • Chambers, J. M. (1998). Programming with Data: A Guide to the S Language. Springer, New York.
  • Chambers, J. M. (2008). Software for Data Analysis: Programming with R. Springer, New York.
  • Chambers, J. M. and Hastie, T., eds. (1992). Statistical Models in S. Chapman & Hall, Boca Raton, FL.
  • Chambers, J. M., Mallows, C. L. and Stuck, B. W. (1976). A method for simulating stable random variables. J. Amer. Statist. Assoc. 71 340–344.
  • Danenberg, P. (2011). rJavax: rJava extensions. R package version 0.3. Available at
  • Eddelbuettel, D. and François, R. (2011). Rcpp: Seamless R and C++ integration. Journal of Statistical Software 40 1–18.
  • Gentleman, R. C., Carey, V. J., Bates, D. M. et al. (2004). Bioconductor: Open software development for computational biology and bioinformatics. Genome Biology 5 R80.
  • Grothendieck, G. and Bellosta, C. J. G. (2012). rJython: R interface to Python via Jython. R package version 0.0-4. Available at
  • Ihaka, R. and Gentleman, R. (1996). R: A language for data analysis and graphics. J. Comput. Graph. Statist. 5 299–314.
  • Odersky, M., Spoon, L. and Venners, B. (2010). Programming in Scala, 2nd ed. Artima, Walnut Creek, CA.
  • Python (2013). The Python Tutorial. Python. Available at
  • R Core Team (2013). R Language Definition. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-13-5. Available at
  • Shalit, A. (1996). The Dylan Reference Manual. Addison-Wesley, Reading, MA.
  • Temple Lang, D. (2014). Enhancing R with advanced compilation tools and methods. Statist. Sci. 29 181–200.
  • Tierney, L. (1990). LISP-STAT: An Object-Oriented Environment for Statistical Computing and Dynamic Graphics. Wiley, New York.