开发者

R substitute on expression with assignment

W开发者_JS百科hy do these two cases behave differently?

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

vs

> substitute(c1=100,list(c1=100))
[1] 100


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
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜