tags:

views:

77

answers:

2

Why do these two cases behave differently?

>substitute(c1<-100,list(c1=100))
100 <- 100

vs

> substitute(c1=100,list(c1=100))
[1] 100
+2  A: 

Because the second expression interprets c1 = 100 as saying the argument named c1 of the function substitute should have value 100.

Jonathan Chang
ok but even if I wrap it in I() it doesn't actually substitue it while for I(c1<-100) it does
frankc
Why do you think `I()` would do anything here?
hadley
+1  A: 

As I understand help to assignOps operator = evaluates immediately. So the second expression is equivalent to substitute(100,list(c1=100)).
But you could take it in braces and the result is

> substitute({c1=100},list(c1=100))
{
    100 = 100
}
Marek