Hello list, I'm doing a table with scores and I want include colors to represent status of an individual. I'm using sweave <<results=tex>>= and xtable but I can't get a result I want. My attemps are
#----------------------------------------------------------------------------- # code R da <- data.frame(id=letters[1:5], score=1:5*2) col <- function(x){ ifelse(x>7, paste("\textcolor{blue}{", formatC(x, dig=2, format="f"), "}"), paste("\textcolor{red}{", formatC(x, dig=2, format="f"), "}")) } da$score.string <- col(da$score) require(xtable) xtable(da[,c("id","score.string")]) #----------------------------------------------------------------------------- actual result #----------------------------------------------------------------------------- \begin{tabular}{rll} \hline & id & score.string \\ \hline 1 & a & extcolor\{red\}\{ 2.00 \} \\ 2 & b & extcolor\{red\}\{ 4.00 \} \\ 3 & c & extcolor\{red\}\{ 6.00 \} \\ 4 & d & extcolor\{blue\}\{ 8.00 \} \\ 5 & e & extcolor\{blue\}\{ 10.00 \} \\ \hline \end{tabular} #----------------------------------------------------------------------------- desired result (lines omited to save space) #----------------------------------------------------------------------------- 1 & a & \textcolor{red}{ 2.00 } \\ 2 & b & \textcolor{red}{ 4.00} \\ #----------------------------------------------------------------------------- Any contribution will be useful. Thanks. Walmes. ========================================================================== Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 ========================================================================== [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.