[R] odfTable: how to escape <

Francesco Cernuto cernuto at unisi.it
Tue Nov 28 11:32:48 CET 2006


Max,

thanks for your suggestions. I 'm now better oriented in reading again 
last October article on Rnews and the odfWeave package documentation.
I realized that odfWeave writes xml output in UTF-8 encoding as 
content.xml first row shows:
|<?xml version="1.0" encoding="UTF-8" ?>
|
As I want also use special characters and accents not only as column, 
but also as row headings, I have directly created a row names character 
vector using xml entities:

In R:

library(odfWeave)
x <- matrix(sample(1:100,24,replace=TRUE),ncol=8)
dimnames(x) <- list(c("Saint 
Honor&#233;","S&#228;cher-Torte","Cr&#232;me Chantilly"),c('< 
35','35-39','40','45-49','50-54','55-59','59-64',' >64'))
odfWeave("test.odt","test.out.odt")


In test.odf document (after adding an extra-column for row names):

<<TabTest, echo=FALSE,results = xml>>=
tabxStyles <- tableStyles(cbind(rep(1,3),x), header=NULL)
odfTable(
x,
useRowNames = TRUE,
colnames = c(“ ”,odfTranslate(dimnames(x)[[2]],toR=FALSE)),
styles=tabxStyles)
@


||Francesco
|


|Kuhn, Max ha scritto:
> Francesco,
>
> odfTable writes out a table in xml format directly into an xml file. The
> issues is that the characters "<" and ">" (among others) have to be
> converted to "&gt;" and "&lt;".
>
> I will build a new version where this happens automatically. In the
> meantime, you should be able to use the colnames argument of odfTable
> and odfTranslate to convert the column headings:
>
>   > odfTranslate("these need to be fixed: < and >", toR = FALSE)
>   [1] "these need to be fixed: &lt; and &gt;"
>
> Max
>
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Francesco Cernuto
> Sent: Friday, November 24, 2006 10:06 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] odfTable: how to escape <
>
> Dear All,
>
> I'm appreciating odfWeave as a nice reporting tool, but I had some pain 
> in producing tables with odfTable command
> where the first column began with < or > such as in age class heading, 
> for example:
> <35
> 35-39
> 40-49
> 50-50
>  >60
> In this case, to avoid a content.xml error, I had to change <35 in less 
> than 35 and > 60 in over 60.
>
> Anyone knows how to escape those characters while producing a table in R
>
> or in a document chunk?
>
>
> Thanks in advance,
>
> Francesco Cernuto
>
> ______________________________________________
> 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.
> ----------------------------------------------------------------------
> LEGAL NOTICE
> Unless expressly stated otherwise, this message is confidential and may be privileged.  It is intended for the addressee(s) only.  Access to this E-mail by anyone else is unauthorized.  If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful.  If you are not an addressee, please inform the sender immediately.
>
>



More information about the R-help mailing list