Liviu Andronic
2009-Jun-30 18:12 UTC
[R] conditional coloring of output text in console or in GUI
Hello, On 6/30/09, Christopher W. Ryan <cryan at binghamton.edu> wrote:> suppose I have some logical vector > > x <- as.logical(c(0,0,0,1,0,0,1,1,0)) > x > > How would I make the words TRUE appear on the screen in a different > color from the words FALSE? >I believe xterm256 would help with this, and perhaps highlight [1]. Liviu [1] http://r-forge.r-project.org/projects/highlight/
Christopher W. Ryan
2009-Jun-30 18:28 UTC
[R] conditional coloring of output text in console or in GUI
suppose I have some logical vector x <- as.logical(c(0,0,0,1,0,0,1,1,0)) x How would I make the words TRUE appear on the screen in a different color from the words FALSE? Thanks. --Chris -- Christopher W. Ryan, MD SUNY Upstate Medical University Clinical Campus at Binghamton 40 Arch Street, Johnson City, NY 13790 cryanatbinghamtondotedu "If you want to build a ship, don't drum up the men to gather wood, divide the work and give orders. Instead, teach them to yearn for the vast and endless sea." [Antoine de St. Exupery]
Christopher W. Ryan <cryan <at> binghamton.edu> writes:> > suppose I have some logical vector > > x <- as.logical(c(0,0,0,1,0,0,1,1,0)) > x > > How would I make the words TRUE appear on the screen in a different > color from the words FALSE? > > Thanks. > > --Chris# install.packages("xterm256") library(xterm256) cat(style(x, fg=c(0,0,0,1,0,0,1,1,0))) HIH Paolo
Romain Francois
2009-Jul-01 11:19 UTC
[R] conditional coloring of output text in console or in GUI
Hi, You might want to check package xterm256. http://cran.r-project.org/web/packages/xterm256/index.html http://romainfrancois.blog.free.fr/index.php?post/2009/04/18/Colorful-terminal%3A-the-R-package-%22xterm256%22 This works if the terminal you are using recognizes xterm escape sequences as defined in this page. http://frexx.de/xterm-256-notes/ It would be possible for other gui to support these escape sequences. Romain On 06/30/2009 08:28 PM, Christopher W. Ryan wrote:> suppose I have some logical vector > > x<- as.logical(c(0,0,0,1,0,0,1,1,0)) > x > > How would I make the words TRUE appear on the screen in a different > color from the words FALSE? > > Thanks. > > --Chris-- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr
Jim Lemon
2009-Jul-01 11:19 UTC
[R] conditional coloring of output text in console or in GUI
Christopher W. Ryan wrote:> suppose I have some logical vector > > x <- as.logical(c(0,0,0,1,0,0,1,1,0)) > x > > How would I make the words TRUE appear on the screen in a different > color from the words FALSE? > >tfsample<-as.logical(sample(c(0:1),10,TRUE)) plot(1:10,type="n") text(1:10,1:10,tfsample,col=ifelse(tfsample,"red","blue")) Jim