I have two variables, as follows:
tokenName = "myToken"
tokenResult = "myResult"
I'd like to set options()
where I evaluate the variable tokenName
and set that option as myResult
.
Essentially I want the equivalent of options(myToken = tokenResult)
, but using the variable tokenName
.
I tried options(eval(tokenName) = tokenResult)
but to no avail. Does anyone have any ideas?
We can use setNames
do.call(options, as.list(setNames(tokenResult, tokenName)))
-checking
options()[[tokenName]]
#[1] "myResult"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.