Skip to content

Instantly share code, notes, and snippets.

@noamross
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noamross/b902d1cda9bedb1bd060 to your computer and use it in GitHub Desktop.
Save noamross/b902d1cda9bedb1bd060 to your computer and use it in GitHub Desktop.
Capturing all console output, including messages from C programs, etc
conn <- textConnection("printed_output", "w", local = TRUE)
sink(conn, type=c("output"))
sink(conn, type=c("message"))
install.packages("ggplot2")
sink(NULL)
printed_output
# This will append the text to the printed_output variable, so clear it beforehand.
#If you get errors in install and your console output disappears, do
# for(i in seq.along(sink.number()) sink(NULL)
@Ironholds
Copy link

[1] ""
[2] "The downloaded source packages are in"
[3] "\t‘/tmp/RtmpeTqYaE/downloaded_packages’"
[4] "Installing package into ‘/home/ironholds/R/x86_64-pc-linux-gnu-library/3.2’"
[5] "(as ‘lib’ is unspecified)"
[6] "trying URL 'http://cran.rstudio.com/src/contrib/ggplot2_1.0.1.tar.gz'"
[7] "Content type 'application/x-gzip' length 2351203 bytes (2.2 MB)"
[8] "=================================================="
[9] "downloaded 2.2 MB"
[10] ""
[11] ""
[12] "The downloaded source packages are in"
[13] "\t‘/tmp/RtmpeTqYaE/downloaded_packages’"

Well, this is weird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment