Reputation: 2351
I would like to make this function within a function print to console:
somefun <- function(x) {
otherfun <- function (x) {
print(x)
}
}
somefun("It works!")
What would be the best way to make this happen?
Upvotes: 0
Views: 67
Reputation: 389275
Call the inner function in the outer function?
somefun <- function(x) {
otherfun <- function (x) {
print(x)
}
otherfun(x)
}
somefun("It works!")
#[1] "It works!"
Upvotes: 1