isParameter | R Documentation |
These functions allow one to query whether a variable name corresponds to either a formal argument/parameter of a given function or to a variable that is created locally in the body of the function, or neither.
isParameter(p, fun)
isLocalVar(p, fun, notParam = TRUE)
p |
the name of the variable to query |
fun |
the R function |
notParam |
a logical value related to how
we treat parameters/formal arguments that are also local variables.
A parameter which has no local assignments to its name will not be considered
a local variable.
However, if there is one or more assignments to that parameter name in the body of the
function, |
A logical value
Duncan Temple Lang
findAssignsTo
formals
f = function(x, y) {
len = length(x)
w = !is.na(x)
(x[w] + y[w])/len
}
isLocalVar("x", f)
isLocalVar("x", f, FALSE)
isLocalVar("w", f)
isLocalVar("len", f)
isParameter("x", f)
isParameter("len", f)
isParameter("other", f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.