LOs for the entire book
- Improve programming skills.
- Develop a deep understanding of R language fundamentals.
- Understand what functional programming means.
- Understand object-oriented programming as applied in R.
- Understand metaprogramming while developing in R.
- Be able to identify what to optimize and how to optimize it.
LOs for this chapter
- Recognize the differences between the 1st and 2nd edition of this book.
- Describe the overall structure of the book.
- Decide whether this book is right for you.
Hadley’s goals
- Improve coverage of concepts Hadley understood better after 1e
- Reduce coverage of unimportant topics
- Easier to understand (including many more diagrams)
Base vs rlang
- 1e used base R almost exclusively
- 2e uses {rlang}, {purrr}, etc
The 5 sections
- Foundations: (7 chapters) Building blocks of R
- Functional programming: (3 chapters) Treating functions as objects (that can be args in functions)
- Object-oriented programming: (5 chapters + 1) The many object systems of R (we’ll add S7)
- Metaprogramming: (5 chapters) Generating code with code
- Techniques: (4 chapters) Debugging, measuring performance, improving performance
Why R?
- Diverse & welcoming community
- Many packages for stats & modeling, ML, dataviz, data wrangling
- Rmarkdown / Quarto
- RStudio / Positron
- Often used in science
- Functional programming powerful for data
- Metaprogramming
- Ease of connection to C, C++, etc
R imperfections
- Much code by non-coders (messy)
- Community more about results than programming best practices
- Metaprogramming can lead to weird failures
- Inconsistency from > 30 years of evolution
- Poorly written R code runs very poorly
Who should read Advanced R?
- Intermediate (and up) R programmers who want to really understand R
- Programmers from other langs who want to know why R is weird
- Prereqs:
- You’ve written lots of code
- You understand basics of data analysis
- You can install CRAN packages
Other books
- The Structure and Interpretation of Computer Programs (Abelson, Sussman, and Sussman, 1996) PDF
- Concepts, Techniques and Models of Computer Programming (Van Roy & Haridi, 2003) PDF
- The Pragmatic Programmer (Hunt & Thomas, 1990) buy eBook