xattached to a name. We can see that with
as.list(substitute(list(x = y)))
Therefore, it is not so easy to change the name in the call substitute. But you can do
e <- substitute(list(x = y), list(y = "bar"))
names(e)[2] <- "foo"
eval(e)
or just substituteyou can change the expression to usesetNames
e <- substitute(setNames(list(y), x), list(x = "foo", y = "bar"))
eval(e)
But you can also use callthat easier
cl <- call("list", foo = "bar")
eval(cl)
source
share