[R] Problems with xtable?

Brian Diggs brian.s.diggs at gmail.com
Fri Dec 13 22:58:29 CET 2013


On 12/13/2013 1:14 PM, Silvano Cesar da Costa wrote:
> Hi,
>
> I'm using Sweave to create some tables. My code is:
>
> <<label=Q1, echo=FALSE, results=tex>>=
> tab1 = table(DISCIPLINA, Q1)
> tab1.prop = round(addmargins(100*prop.table(tab1, 1),
> FUN=list(Total=sum)), 2)
> tab1.txt = xtable(tab1.prop, align="l|rrrrrr", label='Q1',
> caption=c("Apresentação da proposta de programa a ser desenvolvida na
> disciplina", "Q1"))
> print(tab1.txt, format.args=list(big.mark = ".", decimal.mark = ","),
> caption.placement='top', table.placement='H')
> @
>
>
> but, the output is
>
> Margins computed over dimensions
> in the following order:
> 1: DISCIPLINA
> 2: Q1
> % latex table generated in R 3.0.0 by xtable 1.7-1 package
> % Fri Dec 13 19:00:35 2013
> \begin{table}[H]
> \centering
> \caption[Q1]{Apresentação da proposta de programa a ser desenvolvida na
> disciplina}
> \label{Q1}
> \begin{tabular}{l|rrrrrr}
>    \hline
>   & 1 & 2 & 3 & 4 & 5 & Total \\
>    \hline
> 6BAV039 & 5,45 & 20,00 & 40,00 & 29,09 & 5,45 & 100,00 \\
>    6BIO029 & 1,85 & 1,85 & 31,48 & 37,04 & 27,78 & 100,00 \\
>    6BIO030 & 0,00 & 0,00 & 5,45 & 45,45 & 49,09 & 100,00 \\
>    6BIO031 & 0,00 & 1,89 & 45,28 & 30,19 & 22,64 & 100,00 \\
>    6BIQ014 & 0,00 & 0,00 & 9,26 & 42,59 & 48,15 & 100,00 \\
>    6CIF023 & 1,85 & 3,70 & 20,37 & 42,59 & 31,48 & 100,00 \\
>    6EMA024 & 1,85 & 9,26 & 25,93 & 38,89 & 24,07 & 100,00 \\
>    6HIT011 & 0,00 & 0,00 & 3,70 & 27,78 & 68,52 & 100,00 \\
>    6MOR012 & 0,00 & 0,00 & 41,82 & 47,27 & 10,91 & 100,00 \\
>    6PAT013 & 0,00 & 5,56 & 29,63 & 44,44 & 20,37 & 100,00 \\
>    6SOC016 & 3,64 & 9,09 & 38,18 & 29,09 & 20,00 & 100,00 \\
>    Total & 14,65 & 51,35 & 291,11 & 414,43 & 328,47 & 1.100,00 \\
>     \hline
> \end{tabular}
> \end{table}
>
>
> and I don't want this output
>
> Margins computed over dimensions
> in the following order:
> 1: DISCIPLINA
> 2: Q1
>
>
> How can I get out it?

The message is coming from the addmargins function. You can add the 
argument quiet=FALSE to the addmargins call (see the help page for 
addmargins).

Despite the help page referring to it as a "message", it is not really a 
message (in the sense of reported via message()) but is written out with 
cat(). Therefore the typical ways to suppress a message 
(suppressMessages(), etc.) won't work. The quiet argument to addmargins 
is the most straightforward way.

> Thanks,
>
>
> ---------------------------------------------
> Silvano Cesar da Costa
>
> Universidade Estadual de Londrina
> Centro de Ciências Exatas
> Departamento de Estatística
>
> Fone: (43) 3371-4346
>


-- 
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University



More information about the R-help mailing list