removeSource | R Documentation |
When options("keep.source")
is TRUE
, a copy of the
original source code to a function is stored with it. Similarly,
parse()
may keep formatted source for an expression.
Such source reference attributes are removed from the object by
removeSource()
.
removeSource(fn)
fn |
a |
This removes the "srcref"
and related attributes, via
recursive cleaning of body(fn)
in the case of a function
or the recursive language parts, otherwise.
A copy of the fn
object with the source removed.
is.language
about language objects.
srcref
for a description of source reference records,
deparse
for a description of how functions are deparsed.
## to make this act independently of the global 'options()' setting: op <- options(keep.source = TRUE) fn <- function(x) { x + 1 # A comment, kept as part of the source } fn names(attributes(fn)) # "srcref" (only) names(attributes(body(fn))) # "srcref" "srcfile" "wholeSrcref" f2 <- removeSource(fn) f2 stopifnot(length(attributes(fn)) > 0, is.null(attributes(f2)), is.null(attributes(body(f2)))) ## Source attribute of parse()d expressions, ## have {"srcref", "srcfile", "wholeSrcref"} : E <- parse(text ="a <- x^y # power") ; names(attributes(E )) E. <- removeSource(E) ; names(attributes(E.)) stopifnot(length(attributes(E )) > 0, is.null(attributes(E.))) options(op) # reset to previous state
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.