Reputation: 117
I would like to save the the verbose output of whatever R function to either a variable or file.
In other words, the verbose console output of whatever_R_function(abc, verbose=TRUE)
should be saved somewhere.
I tried to play with verbose.output <- capture.output(whatever_R_function(abc, verbose = TRUE))
but it doesn't work as capture.output()
captures the non-verbose part of the output only.
Two examples:
install.packages('devtools', verbose=TRUE)
or
library(emayili)
smtp <- server(host = '...',
port = ...,
username = '...',
password = '...')
email <- envelope() %>%
from('...') %>%
to('...') %>%
bcc('...') %>%
reply('...') %>%
subject('...') %>%
html('...') %>%
attachment('...')
smtp(email, verbose = TRUE)
Thank you.
R 4.0.2 - RStudio 1.3.1093 - macOS 10.15.7
Upvotes: 0
Views: 924
Reputation: 146050
I didn't dig in to the install.packages
code, but smtp
appears to use cat
directed to stderr()
when verbose = TRUE
.
The ?capture.output
help page says:
Messages sent to
stderr()
(including those frommessage
,warning
andstop
) are captured bytype = "message"
. Note that this can be “unsafe” and should only be used with care.
So, I believe if you use capture.output(..., type = "message")
, you should get it. There's a strong possibility that this will work for install.packages
too.
I'm not sure why this is considered unsafe or what care you should take with it...
Upvotes: 1