You can use keep.outputs
install.packages("stringr", keep.outputs=TRUE)
from the help
if true, keep the outputs from installingsource packages in the current working directory, with thenames of the output files the package names with ‘.out’ appended ...
Note, instead of TRUE
can be a character string of the directory where to save the output.
Also, there are several warnings and keep-in-minds regarding the usage of sink
, like
Sink-ing the messages stream should be done only with great care.
and
Do not sink the messages stream unless you understand the sourcecode implementing it ...
Open and closing connections can be tricky and error prone, plus there might be operating system pitfalls and specificities etc.