9

Suppose I want to print HTML tables using xtable, side-by-side. I tried doing this in an .Rmd file with:

<table border = 1>
<tr>
<td>
`r functionThatPrintsAnHTMLTableUsingxtable`
</td>
<td>
`r functionThatPrintsAnotherHTMLTableUsingxtable`
</td>
</tr>
</table>

No dice. What am I doing wrong? Thanks.

Brash Equilibrium
  • 1,357
  • 4
  • 14
  • 35

1 Answers1

20

I think your code will work if you put results=asis in the chunk options.

<table border = 1>
<tr>
<td>
```{r results='asis', echo=FALSE}
  library(xtable)
  data(tli)
  print(xtable(tli[1:20, ]),type='html')
```
</td>
<td>
```{r results='asis', echo=FALSE}
  library(xtable)
  data(tli)
  print(xtable(tli[1:20, ]),type='html',comment=FALSE)
```
</td>
</tr>
</table>
Brash Equilibrium
  • 1,357
  • 4
  • 14
  • 35
nograpes
  • 18,623
  • 1
  • 44
  • 67
  • 5
    There is one issue with this: For some reason, an HTML comment tag shows up with the second table. This is fixed by specifying the `comment` attribute of `print.xtable()` as `FALSE` – Brash Equilibrium Jan 29 '14 at 22:50