powered by
This function grabs a symbol out of an expression and returns it as a character (see details for which symbol will be used).
This is a convenience function for use when constructing custom function handlers, it's unlikely to have much utility outside of that context.
asVarName(x)
A character vector of length one representing the symbol (or literal) as described in the Details section.
The (sub)expression to extract a symbol from
Duncan Temple Lang
This function always returns a character vector representing a single symbol from x, but which code varies depending on the exact form of x. When
x
the character representation of the symbol is returned
asVarName is recursively called on the sub-expression for the first argument
asVarName is called recursively on the right-hand side (after -> expressions are transformed to <- ones). This is a special case of the rule above.
->
<-
asVarName(quote(rnorm(x, y, z))) # "x" asVarName(quote(rnorm(x, y, z))[[1]] ) # "rnorm" b/c [[1]] is called fun asVarName(quote(rownames(a) <- b )) # "a" asVarName(quote(rnorm(10, y, z))) # "10"
Run the code above in your browser using DataLab