asVarName

0th

Percentile

asVarName

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.

Keywords
programming , misc , utitlites
Usage
asVarName(x)
Arguments
x

The (sub)expression to extract a symbol from

Details

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 is a single symbolthe character representation of the symbol is returned

  • x is a function callasVarName is recursively called on the sub-expression for the first argument

  • x is an assignmentasVarName is called recursively on the right-hand side (after -> expressions are transformed to <- ones). This is a special case of the rule above.

Value

A character vector of length one representing the symbol (or literal) as described in the Details section.

Aliases
  • asVarName
Examples
# NOT RUN {
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"
# }
Documentation reproduced from package CodeDepends, version 0.6.5, License: GPL

Community examples

Looks like there are no examples yet.