Question

I am using the following R code to call xtable and generate a LaTeX table for a Sweave document.

ifelse(LaTeX==1, print(xtable(rule1.results.noTC, caption="Rule 1 Results 0 Transaction Costs",
                          digits=c(1,2,4,4,4), display=c("d","d","f","f","f"))), 
   print(rule1.results))

This produces the following LaTeX

% latex table generated in R 3.0.1 by xtable 1.7-1 package
% Sun Jul 28 16:54:42 2013
\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
  \hline
 & L & profits & annCumulExReturn & sharpe \\ 
  \hline
1 &   5 & -888.8215 & -0.1501 & -4.3939 \\ 
  2 &  10 & -909.8941 & -0.1533 & -6.8882 \\ 
  3 &  20 & -893.6245 & -0.1509 & -6.9081 \\ 
  4 &  40 & -865.6764 & -0.1466 & -9.8462 \\ 
  5 &  80 & -832.4700 & -0.1417 & -11.7260 \\ 
  6 & 160 & -757.0690 & -0.1305 & -16.3088 \\ 
  7 & 320 & -626.9162 & -0.1118 & -31.6134 \\ 
  8 & 640 & -340.8740 & -0.0730 & -44.2321 \\ 
   \hline
\end{tabular}
\caption{Rule 1 Results with Transaction Costs} 
\end{table}

When I convert this to pdf, I get a nice table. However, it is followed by a weird note: [1] "

And I get several of these if I plot multiple tables in a row. How can I eliminate this either via R's xtable or by editing the LaTeX code.

Thanks

Was it helpful?

Solution

I can't say for sure without your data and an example of the .tex file, but I'm pretty confident this is due to your use of ifelse. I imagine the following will not give you the weird print out:

if(LaTeX==1) {
    print(xtable(rule1.results.noTC,caption="Rule 1 Results 0 Transaction Costs",
                 digits=c(1,2,4,4,4), display=c("d","d","f","f","f")))
} else {
    print(rule1.results))
}

This is because ifelse returns its result, which you're also printing. See, for example:

> ifelse(TRUE,print("true"),print("false"))
[1] "true"
[1] "true"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top