[R] Greek symbols in xtable rows

James W. MacDonald jmacdon at med.umich.edu
Tue Apr 17 17:01:01 CEST 2007


Roger Bivand wrote:
> Andris Jankevics <andza <at> osi.lv> writes:
> 
> 
>>Thank You for answer. I Tried code that You provided in reply to my question 
>>on both PC's with Linux and Widows OS.
>>
>>On linux box output is:
>>
> 
> 
> ...
> 
> 
>>System information:
>>
>>
>>>sessionInfo ()
>>
>>R version 2.4.0 (2006-10-03)
>>i686-redhat-linux-gnu
>>
>>locale:
>>LC_CTYPE=lv_LV.UTF-8;LC_NUMERIC=C;LC_TIME=lv_LV.UTF-8;LC_COLLATE=lv_LV.UTF-
> 
> 8;LC_MONETARY=lv_LV.UTF-8;LC_MESSAGES=lv_LV.UTF-8;LC_PAPER=lv_LV.UTF-
> 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=lv_LV.UTF-
> 8;LC_IDENTIFICATION=C
> 
>>attached base packages:
>>[1] "tcltk"     "methods"   "stats"     "graphics"  "grDevices" "utils"
>>[7] "datasets"  "base"
>>
>>other attached packages:
>> xtable     pls ellipse
>>"1.4-3" "1.2-1" "0.3-2"
>>
>>And there is an output form my windows PC:
>>
>>
>>>mat <- diag (c("$\\sigma_1^2","$\\sigma_2^2$"))
>>>xtable (mat)
> 
> 
> ... (replicates for me on same system)
> 
> 
>>>sessionInfo ()
>>
>>R version 2.4.1 (2006-12-18) 
>>i386-pc-mingw32 
>>
>>locale:
>>LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
>>States.1252;LC_MONETARY=English_United 
>>States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>>
>>attached base packages:
>>[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"   
>>"base"     
>>
>>other attached packages:
>> xtable 
>>"1.4-3" 
> 
> 
> Yes, I have also been bitten by the "upgrade" to xtable, which between 1.4-2 
> and 1.4-3 added code to try to be cleverer, but has broken output of LaTeX 
> markup directly. The offending code starts around line 177 in print.xtable.R 
> (#based on contribution from Jonathan Swinton <jonathan at swintons.net> in e-
> mail dated Wednesday, January 17, 2007). I did try to write a 
> sanitize.text.function= solution, but failed, and backed off to an earlier 
> version. Could the maintainer David Dahl, please address this, and include a 
> relevant test? (I would CC him, but am travelling and posting via gmane to keep 
> thr thread together - I apologize for pruning, but gmane won't post otherwise).
> 
> So a solution is to install an earlier version of xtable from the package 
> archives, a harder but feasible task for Windows.

The solution is to use a workable sanitize.text.function.

 > mat <- diag(c("$\\sigma_1^2$","$\\sigma_2^2$"))
 > tbl <- xtable(mat)
 > print.xtable(tbl, sanitize.text.function = function(x) x)
% latex table generated in R 2.5.0 by xtable 1.4-3 package
% Tue Apr 17 11:00:05 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{rll}
   \hline
  & 1 & 2 \\
   \hline
1 & $\sigma_1^2$ & 0 \\
   2 & 0 & $\sigma_2^2$ \\
    \hline
\end{tabular}
\end{center}
\end{table}

Best,

Jim




> 
> Roger
> 
> 
> ...
> 
> 
>>Thank You,
>>
>>Andris Jankevics
>>
>>On Pirmdiena, 16. Aprīlis 2007 22:38, Charles C. Berry wrote:
>>
>>>On Mon, 16 Apr 2007, Andris Jankevics wrote:
>>>
>>>
>>>>mat <- diag(c("$\\sigma_1^2$","$\\sigma_2^2$"))
>>>>xtable(mat)
>>>
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.


-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623


**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues.



More information about the R-help mailing list