开发者

R substitute on expression with assignment

开发者 https://www.devze.com 2022-12-28 06:45 出处:网络
W开发者_JS百科hy do these two cases behave differently? >substitute(c1<-100,list(c1=100)) 100 <- 100

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

精彩评论

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