[R] Colored output in terminal emulator

Jakson Alves de Aquino jalvesaq at gmail.com
Tue Nov 15 03:34:48 CET 2011


Hi,

I wrote a small patch to make it possible to get colored output from R
running in a Linux terminal emulator. It's a dirty patch. I hope that
someone with better knowledge of R source code and C programming will
improve it. To force the use of Rstd_WriteConsoleEx function
(src/unix/sys-std.c) I edited the file src/unix/system.c and I copied
four lines from an AQUA #ifdef preprocessor directive and pasted them
outside the condition. Then I edited the Rstd_WriteConsoleEx function
to change the colors of the output: errors and warnings are red,
normal output is green and numbers are yellow. If anyone is interested
in trying the patch, here how to do it:

1) Copy the file rcolor.patch to R-2.14.0/src/unix/ directory.
2) Go to the R-2.14.0/src/unix directory and do the following command:

patch -p3 < rcolor.patch

3) Compile R.
4) Put in your ~/.Rprofile:
options(color.output = TRUE)

The patch is attached and a screenshot is available at
http://www.lepem.ufc.br/jaa/R_color_output.png

-- 
Jakson Aquino


More information about the R-help mailing list