'How can I get output code for Latex from my R code?
library(summarytools)
library(stargazer)
view(dfSummary(DataV2,graph.col = TRUE), method = "render")
Solution 1:[1]
I don't think summarytools has a way to produce LaTeX directly, but it can produce Markdown output, and the rmarkdown package can convert that to LaTeX. For example:
---
title: "Untitled"
date: "17/02/2022"
output:
pdf_document:
keep_tex: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r results='asis'}
library(summarytools)
library(stargazer)
dfSummary(tobacco,
plain.ascii = FALSE,
style = 'grid',
graph.magnif = 0.85,
varnumbers = FALSE,
valid.col = FALSE,
tmp.img.dir = "/tmp")
```
Because I used the keep_tex: true option in the YAML, it outputs the .tex file as well as the PDF, and you could theoretically extract the LaTeX from there if you weren't using R Markdown for the rest of the document. It might not be easy, because of all the embedded figures.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user2554330 |
