There is some strange formatting in this part of the Evaluation chapter (see below image). I think it is due to the sidebar
styling.
|
::: sidebar |
|
**Expression vectors** |
|
\index{expression vectors} |
|
|
|
`base::eval()` has special behaviour for expression _vectors_, evaluating each component in turn. This makes for a very compact implementation of `source2()` because `base::parse()` also returns an expression object: |
|
|
|
```{r} |
|
source3 <- function(file, env = parent.frame()) { |
|
lines <- parse(file) |
|
res <- eval(lines, envir = env) |
|
invisible(res) |
|
} |
|
``` |
|
|
|
While `source3()` is considerably more concise than `source2()`, this is the only advantage to expression vectors. Overall I don't believe this benefit outweighs the cost of introducing a new data structure, and hence this book avoids the use of expression vectors. |
|
::: |
