Thanks to Alyssa Frazee I just learned about the
colorout package (Aquino, 2013). It modifies
R so that the output is in different colors, making it much more pleasant to use
R in the terminal.
Do note that
colorout is not available from CRAN, but you can easily install by following the instructions on the
colorout site (Official site) reproduced below:
download.file("http://www.lepem.ufc.br/jaa/colorout_1.0-2.tar.gz", destfile = "colorout_1.0-2.tar.gz") install.packages("colorout_1.0-2.tar.gz", type = "source", repos = NULL)
The next step is to then load
colorout automatically when I start
R. The problem is that I don’t use
R solely on the terminal. I easily figured out how to do so thanks to the error message you get when attempting to load
colorout on the R GUI. I thus ended up adding the following lines to my
.Rprofile (both locally and in the cluster):
## Change colors when running R in the terminal if (Sys.getenv("TERM") == "xterm-256color") library("colorout")
Now I have pretty
R output in the terminal! Thanks again Alyssa! See her original tweet below:
problem: R output in Terminal isn't colorful. SOLUTION: http://t.co/Vd6OoRoUU5
— Alyssa Frazee (@acfrazee) February 17, 2014
colorout has been around for a while and was even at CRAN for some time. I guess that I’m just late to the party.
If the default
colorout colors don’t work for you, check functions such as
setOutputColors256. This post shows how you can do it and includes screenshots of the output. Other package details are included here and here.
Citations made with
knitcitations (Boettiger, 2014).
- Jakson Aquino, (2013) colorout: Colorize R output on terminal emulators. http://www.lepem.ufc.br/jaa/colorout.html
- colorout. http://www.lepem.ufc.br/jaa/colorout.html
- Carl Boettiger, (2014) knitcitations: Citations for knitr markdown files. http://CRAN.R-project.org/package=knitcitations
## R version 3.0.2 (2013-09-25) ## Platform: x86_64-apple-darwin10.8.0 (64-bit) ## ## locale: ##  en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 ## ## attached base packages: ##  stats graphics grDevices utils datasets methods base ## ## other attached packages: ##  knitcitations_0.5-0 bibtex_0.3-6 knitr_1.5 ## ## loaded via a namespace (and not attached): ##  codetools_0.2-8 digest_0.6.4 evaluate_0.5.1 formatR_0.10 ##  httr_0.2 RCurl_1.95-4.1 stringr_0.6.2 tools_3.0.2 ##  XML_3.95-0.2 xtable_1.7-1
Check other topics on #rstats.