0

I am using the reticulate package to include R and Python code in an R Markdown file.

The context is: I am using lavaan for structural equation modeling in R and sympy in Python. I don't know of a good SEM module for Python (semopy seems underdeveloped at the moment) and sympy is much better than the R CAS packages that I am aware of (e.g. Ryacas).

The code chunks for both languages are formatted the same. It is not that hard to read over the chunks and figure our which language is being used, but I'd like to make it more obvious by having them formatted differently, possibly with a different color scheme or fonts. Is this possible and easily implemented?

hendogg87
  • 145
  • 1
  • 5
  • Perhaps using knitr options for "code decoration" (https://yihui.org/knitr/options/#code-decoration) might help you there. The simpler way would be to give different background colors for each code chunk, using the `background` option (LaTeX) or `class.source` (HTML) – jmcastagnetto Nov 29 '19 at 15:19
  • Thanks, the backgound idea worked well. I found another post that shows how to specify different backgrounds on a per chunk basis: https://stackoverflow.com/questions/41030477/changing-chunk-background-color-in-rmarkdown. – hendogg87 Dec 02 '19 at 08:23

0 Answers0