library(evaluate)
# normally you cannot capture the output of system
evaluate("system('R --version')")
# replace the system() function
old <- inject_funs(system = function(...) {
cat(base::system(..., intern = TRUE), sep = "\n")
})
evaluate("system('R --version')")
# restore previously injected functions
inject_funs(old)
Run the code above in your browser using DataLab