As @Suren has pointed out, it will be suitable to know from which package comes new_renderer
. To illustrate this, consider the following example, where we're going to nest the lm
function from stats
package inside a custom_function
. Additionnally, we're going to describe the function by calling body
and deparse
on it.
require(stats)
custom_function <-
function(x, y) {
result <- lm(x, y)
return(result)
}
Now, to get the body of custom_function
I would call body
on it (alternatively deparse
), the expected output is
deparse(custom_function)
>>>
[1] "function (x, y) " "{" " result <- lm(x, y)"
[4] " return(result)" "}"
body(custom_function)
>>>
{
result <- lm(x, y)
return(result)}
Notice that custom_function
is calling lm
, which is a function of the stats
package. Therefore, when I call deparse
on lm, it will get the description (the source code of the nested function) of it.
deparse(lm)
>>>
[1] "function (formula, data, subset, weights, na.action, method = \"qr\", "
[2] " model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, "
[3] " contrasts = NULL, offset, ...) "
[4] "{"
[5] " ret.x <- x"
[6] " ret.y <- y"
...
...
If I only want to see the body of the function, I would call
body(lm)
>>>
{
ret.x <- x
ret.y <- y
cl <- match.call()
mf <- match.call(expand.dots = FALSE)
...
...
As conclusion, this approach worked out because we know from which package does the lm
function comes from.