adv-r icon indicating copy to clipboard operation
adv-r copied to clipboard

Chapter 6.3 Composition -- nitpicking?

Open jimrothstein opened this issue 5 years ago • 0 comments

Just before section 6.4, the v.2 of Advanced R has following paragraphs:

`Each of the three options has its own strengths and weaknesses:

Nesting, f(g(x)), is concise, and well suited for short sequences. But longer sequences are hard to read because they are read inside out and right to left. As a result, arguments can get spread out over long distances creating the Dagwood sandwich problem.

Intermediate objects, y <- f(x); g(y), requires you to name intermediate objects. This is a strength when objects are important, but a weakness when values are truly intermediate.

Piping, x %>% f() %>% g(), allows you to read code in straightforward left-to-right fashion and doesn’t require you to name intermediate objects. But you can only use it with linear sequences of transformations of a single object. It also requires an additional third party package and assumes that the reader understands piping.`

### NOTE: As written The composition they evaluate to is not consistent: f.g g.f g.f

jimrothstein avatar May 09 '20 22:05 jimrothstein