deparse(expr, short=F)
The value of deparse is a character vector, with as many elements as there would be lines in the output of dput for the same object. Contrast this with as.character, which guarantees to return a character vector of the same length as the object it got as argument. (This is not likely what you wanted, if you started with an S-PLUS expression object.) The other extreme, more common, is that you want to get a single character string containing the deparsed code. To get this, paste(deparse(expr), collapse = ""\n"") If the string should have no internal new lines, use some other string for collapse(), but remember in this case that the string will not in general parse correctly to get back expr.
This is a generic function; currently there are no methods defined for it.
z$model <- deparse(model) # save a symbolic form of an argument# label a plot with the definition of a one-line function f plot(x, f(x), ylab=deparse(f)[2], type="l")
foo <- function(x, y) x^y deparse(foo) [1] "function(x, y)" "x^y" as.character(foo) [1] "" "" "x^y"