deparse
Turn a Parsed Expression into Character Form

### Description

Returns a vector of character strings representing the input expression.

### Usage

    deparse(expr, width.cutoff = 60L,
            backtick = mode(expr) %in% c("call", "expression", "(", "function"),
            control = c("keepInteger", "showAttributes", "keepNA"), nlines = -1L)
    deparse1(expr, collapse = " ", width.cutoff = 500L, ...)

### Arguments

expr | any expression.
width.cutoff | the maximum number of characters on a line. Must be between 20 and 500. the default is 60. Note that a line might be longer if deparse fails to find a good way to split the expression.
backtick | a logical flag. If TRUE, symbol names are escaped with backticks when needed. If FALSE, symbol names are not escaped. This technique can be useful (and more readable) when you want the result to be displayed as a label, but it is not possible to parse the result.
control | a vector of character strings that indicate which kind of options you are trying to set. A valid combination includes the following: "all" "keepInteger" "quoteExpressions" "showAttributes" "useSource" "warnIncomplete" "delayPromises" "keepNA" "S_compatible" "noSplitLines" Note that "all" specifies all options on this list except "delayPromises", "S_compatible", and "noSplitLines". If mode(expr) is "call" or "name", and the control with "quoteExpressions" is set, the result is surrounded by "quote()". If mode(expr) is "call", and control with "S_compatible" is set, the integer changes to double.
nlines | the maximum number of lines to return.
collapse | deparse1(expr, collapse, width.cutoff, ...) calls paste(collapse=collapse, deparse(expr, width.cutoff=width.cutoff, ...)).
... | deparse1 passes all unrecognized arguments to deparse.

### Details

Usually, deparsing expressions to print them is not necessary. For example, coercing an expression to mode "character" with the as.character function usually achieves the same effect in a simpler way. However, as the following two examples demonstrate, there are differences between deparse and as.character.
In the first example, the value of deparse is shown when you have a character vector with as many elements as there are lines in the output from dput(expr). Contrast this with calling as.character, which returns a character vector the same length as the input object. Most likely, that is not what you want if you started with an expression object.
In the second example, you want a single character string containing deparsed code. To get this single character string, use deparse1 (but the string might not always parse correctly to recover expr).
Value
deparse returns a character vector containing the deparsed expression. Each element of the character vector corresponds to a line of output from dput(expr). deparse1 returns a single character string containing the results of the corresponding call to deparse pasted together with collapse pasted between each line.
Differences between Spotfire Enterprise Runtime for R and Open-source R

- Spotfire Enterprise Runtime for R has the extra control parameter noSplitLines.
- In Spotfire Enterprise Runtime for R, deparse currently supports only the control parameters 'keepInteger', 'keepNA', 'showAttributes', 'useSource', and (the Spotfire Enterprise Runtime for R-specific) 'noSplitLines'.

See Also
dput, parse, paste, substitute, get, .deparseOpts.
Examples

    ex <- parse(text="mean(1:10)")
    deparse(ex)
    f <- function(x, y=1) { x+y }
    deparse(f)
    deparse1(f)

Package base version 6.1.5-18
Package Index