Jupyter Notebook + R + nbconvert ... tables?

Hi,

so I am currently transitioning from R Markdown back to jupyter notebooks. One problem I simply cannot wrap my head around is getting tables to display both in the actual notebook (while interactively writing it) and my final .pdf output that I create using

jupyter nbconvert --to markdown analysis.ipynb
pandoc -s analysis.md -t latex -o analysis.pdf --filter pandoc-citeproc --bibliography=references.bib --csl=apa.csl

pandoc works fine, so the problem must lie with nbconvert. In R Markdown, I just use knitr::kable or pander, but even if I create markdown output, that is not properly translated in a latex table (instead it shows the raw markdown output…). How do you do that properly?

Best wishes,

Kevin

This isn’t exactly a solution to your problem, but just a note that pandoc now supports ipynb as a native format, so maybe you’d get a different result just doing pandoc myntbk.ipynb --to markdown myntbk.md?

thanks, unfortunately doesn’t seem to solve my problem. Is there really no way of doing what the results='asis' option in R Mrkdown + knitr does (https://bookdown.org/yihui/rmarkdown/r-code.html)?

Can you share an example of a notebook that you’re trying to convert in this way? (and another question to clarify: you’re talking about writing your own Markdown tables in the notebook, or outputting a markdown table using code?

unfortunately not, but sorry, my bad - should’ve provided a minimal (not) working example anyway. I’ll try to get something together, might be a lil while though.
The latter, by code!

1 Like

Interesting, so you want to do something that emits raw markdown, so like

print("**This is markdown*\n# And a header")

and have that get rendered as a table (not markdown) in the PDF?
?

sure, are you familiar with R Markdown + knitr? (works with python as well ;))

I’m familiar but haven’t used it too much, it seems cool!