Say I have a function defined as follows:
myFun <- function(x, y) {
return(2*x + y)
}
I can print the function's definition by simply typing myFun
without parentheses in the console:
> myFun
function(x, y) {
return(2*x + y)
}
How can I return (or print) both the name and the function? That is, I want the console (printed) output to be:
myFun <- function(x, y) {
return(2*x + y)
}
If it's not possible to print the code that defined the function, is there a way to cat
or print
in such a way that I can prepend the normal result of myFun
with the text "myFun <- "?