Chapter 18 Expressions

I understand how we can subset expression calls but why/when would you do that? What is the context for extracting stuff from a function as an expression ?

Let’s build on this contrived example….

Making this an expression, we can use subsetting to shove in read.csv or read.tsv where read.table is?

You might need to do this in order to insert a line of code inside a function call:

## function (x) 
## {
##     read.csv("important.csv", row.names = FALSE)
## }

What’s an application for this chapter?

## a + f(x) + 1

Why does the expression jump around between “data” and “values” on the env panel in RStudio? It would be nice if it stayed in the “data” pane so you can inspect it

It is interpreting x = 1 as an argument to expression. To quote equality you can do parse(text = "x = 1") and the output will print the same, but it isn’t

Does all this go out the book if someone uses "abc" -> x?

"abc"->x is internally parsed as x <- "abc"

## x <- "xyz"

Can you clarify the difference between: - call - language - expression - structure

## [1] TRUE
## [1] TRUE

xxx

When would I use quote() over expression()?

Hadley advises not to use expression(), because it just makes a vector of expressions. He prefers lists of expressions, which you’d generate interactively with quote() (or inside functions with substitute()). We’ll touch on the borders of this at least tonight.