ocean
ocean

Reputation: 55

How to export Latex table to PDF in R?

I produced a table in R and used Hmisc:latex to convert it to latex, but now I am not sure how to render the Latex result to a PDF table. Here is the code:

 latex(tabular((Preoculars +Postoculars + 
 Loreals+Ventral.scale+Dorsal.scale.A+Head.Width+Head.Length+
 Temporals+Supralabials+Infralabials+Subcaudals+Dorsal.scale.B+Dorsal.scale.C+
  SVL+Tail.length+Number.of.rings+SL) ~ 
 ((Subspecies)*((n=1) +mean+sd)), data=dat))

Upvotes: 0

Views: 976

Answers (1)

jeremycg
jeremycg

Reputation: 24955

It really depends on your workflow - using RMarkdown, inside of RStudio, once you have latex installed, you can use this (nb I'm using example data) as your .rmd file:

---
output: pdf_document
---

```{r, results ='asis'}
library(Hmisc)
library(tables)
latex(tabular((Species + 1) ~ (n=1) + Format(digits=2)*
             (Sepal.Length + Sepal.Width)*(mean + sd), data=iris))
```

Then click convert to pdf.

Upvotes: 1

Related Questions