Review: Advanced R by [[Hadley Wickham]]
Advanced R
has a large number of very short chapters across 450 pages, a format it probably owes to its online availability.
The author knits together
- what R is
- some elements of development workflow
- what competent R looks like segueing into
- why R's idiosyncracies are, which involved spiritually reliving The LLVM Cookbook (without LLVM),
- and how to make slow R sufficiently fast.
The work and author are an active part of the R community.
Why was I here aside introspection
I jumped ship from matlab to scipy in early 2014. It seemed more vibrant, and didn't involve buying licenses.
Python in the wild has seemed increasingly jumbled, unmotivated and terminally newbie, so in 2019 I decided to jump back into a ship: R.
The stats department at Waikato University endorses R (kiwi as) and I have had commercial encounter with Apache Spark.
Why R?
I wanted a high level interactive language that fit in with and between Emacs org-mode and low level cluster / gpu implementation.
Emacs speaks statistics and R fit that bill beautifully out of the box.
Lights
High
- Foundations building up to generic functions and S3 classes were a great refresher and primer
- Quick breakdown and examples of functional programming
- Walkthrough applications of R's deep reflection powers
- Advice about and for performant programming
- Great forwarding to further books and online resources
Low
- I would have liked less context around traversing R's abstract syntax tree even though it was useful
- Paid attention to RStudio and Windows installs without mentioning ESS
- Long written urls everywhere in an ebook
- Mangled LaTeX rendering in chapter about LaTeX
Exercises
I diverged from the prescribed exercises to just skimming them and then poking around independently in Foundations somewhere.
They were interesting to read and think about.
Did not ace any of the can-skip-this-section quizes :(.
Playing with R with ESS with org-babel aside
Since I was not using R Studio!
## Make and enter a source block <s <return> R C-c ' ## Evaluated line-by-line C-<return> ## Evaluate buffer C-c M-b ## To leave C-c '
In the containing .org, C-c C-c within the source block evaluates
#+BEGIN_SRC R :results output M <- matrix( 1:10, ncol=2 ) t( lapply( M, mean ) ) #+END_SRC #+RESULTS: : [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] : [1,] 1 2 3 4 5 6 7 8 9 10
Load R org-babel evaluation:
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . nil) (R . t) (latex . t)))
(I like to evaluate elisp with M-x eval-buffer in scratch. Note that org-babel latex doesn't seem to play nicely with org-mode Latex.)
Table of Contents, marked done when I remembered to.
DONE Introduction [8/8]
DONE Who should read this book
DONE What you will get out of this book
DONE Meta-techniques
DONE Recommended reading
DONE Getting help
DONE Acknowledgments
DONE Conventions
DONE Colophon
DONE Foundations [8/8]
DONE Data structures [5/5]
DONE Subsetting [5/5]
- DONE Data types
[7/7]
- DONE Subsetting operators
[4/4]
- DONE Subsetting and assignment
- DONE Applications
[9/9]
- DONE Lookup tables (character subsetting)
- DONE Matching and merging by hand (integer subsetting)
- DONE Random samples/bootstrap (integer subsetting)
- DONE Ordering (integer subsetting)
- DONE Expanding aggregated counts (integer subsetting)
- DONE Removing columns from data frames (character subsetting)
- DONE Selecting rows based on a condition (logical subsetting)
- DONE Boolean algebra vs. sets (logical & integer subsetting)
- DONE Exercises
- DONE Lookup tables (character subsetting)
- DONE Answers
DONE Vocabulary [5/5]
DONE Style guide [3/3]
package formatR ?