I think the @joran answer is right, but maybe I will try to explain in a different way.
The function ( "in R is essentially an identical function. It repeats what you pass. It is almost as if it is not. There is no difference between what will be returned by these operators
x #1 (x) #2 ((x)) #3
The parentheses are just the value inside. You can add as many brackets as you want, and this will not change the return. The evaluator looks at ((x)) , see the outer bracket and knows how to simply return the value of the thing inside the bracket. So now he parses only (x) , and again he sees the outer bracket and just returns the value inside the bracket, which is equal to x . The brackets just go through, although the meaning is inside; they do not value it.
The bare value of x is the name (or character). The name is not uniquely associated with the value. The mapping between names and values is different from the environment. Therefore, names must be evaluated in a specific context in order to obtain meaning. Consider these examples
aa <- 5 dd <- data.frame(aa=20) x <- as.name("aa") foo <- function(x) {aa<-10; eval(x)} eval(x)
This behavior is really very desirable. This is what makes functions requiring a non-standard assessment, such as
subset(mtcars, hp<100)
When you use the R console, it behaves like REPL - it reads your input, evaluates it, prints it, and then waits for the next input. Please note that only one level of evaluation and evaluation occurs in the "current" environment. It does not recursively evaluate the return value from an expression. Therefore when you do
x <- as.name("aa") x
when the REPL goes to the evaluation step, it evaluates the name x , which points to the name aa . It. One level of assessment. The name aa not subsequently evaluated.
There is a note on the ?eval help page:
eval evaluates its first argument in the current scope before passing it to the evaluator
There is no "double" rating. It simply evaluates its parameters just like any other function in R. For examples
aa <- 5 bar <- function(x) print(x) bar(aa+2)
It prints "7", not "aa + 2", because the function checked its parameter before printing. It also explains the differences between the two.
dd <- data.frame(bb=20) xx <- as.name("bb") eval(bb, dd)
In the first call to eval() R cannot evaluate bb in the current environment so that you get an error. But keep in mind that
evalq(bb, dd)
works because evalq does not try to evaluate the first parameter of the expression.