curly_arg | R Documentation |
Curly parameters are processed using NSE, unless they are encapsulated in
curlies {}
, which optionally triggers standard evaluation. This function
is only intended to be used inside another function, and it is used in
a very similar way to match.arg()
. The examples are very useful ...
curly_arg(param)
param |
The parameter to process as a curly param. |
# Not run automatically because curly_arg() is private
## Not run:
# Usage of curly_arg() compared with match.arg()
curly_demo <- function(x, y = c("yes", "no")) {
x <- zfit:::curly_arg(x)
y <- match.arg(y)
x
}
myparam <- "a string"
myvector <- c("string 1", "string 2")
curly_demo(a_symbol) # NSE ON
curly_demo("a string") # NSE disabled with "" for constant strins
curly_demo({"curly-wrap"}) # NSE disabled with {}
curly_demo(c("a","b")) # NSE ON, usually not wanted, quoting preferred
curly_demo({c("a","b")}) # NSE disabled with {}, allowing vectors
curly_demo(myparam) # NSE ON, even if a value exists for myparam
curly_demo("myparam") # NSE disabled, result is a string constant
curly_demo({myparam}) # NSE disabled, value of myparam propagates
curly_demo({myvector}) # NSE disabled, value of myvector propagates
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.