# get function from namespace instead of possibly getting
# implementation shipped with recent R versions:
bp_capture.output <- getFromNamespace("capture.output", "backports")
captured <- bp_capture.output({ message("hi") }, type = "message")
str(captured)
Run the code above in your browser using DataLab