I have a bunch of quite big tables in markdown that I created manually. I was using them in an Rmd document. Since I need more control with LaTeX and all, I am using a Rnw document. How can I put my markdown table in the Sweave file?
Below a minimal example (not working):
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
% my markdown table
col1 | col2 | col3
------|:---:|:---:
row1 | cell1 | cell2
row2 | cell3 | cell4
row3 | cell5 | cell6
\end{document}
I've tried to convert the table inside the document, just to paste the table in markdown in the Sweave document, and get it rendered in LaTeX. My try yields errors, but I am closer:
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<texifytable, echo=FALSE, results=tex>>=
mytab = sprintf("col1 | col2 | col3
------|:---:|:---:
row1 | cell1 | cell2
row2 | cell3 | cell4
row3 | cell5 | cell6")
system2("pandoc", args = c("-f markdown","-t latex"),
stdout = TRUE, input = mytab)
@
\end{document}