R Syntax highlighting from knitr to ghost.io blog - r

I am starting up a blog for R models and I currently use knitr and R markdown to produce documents. What I have tried to do is just copy the HTML from the the knitr output into the ghost.io blog, and it works perfectly with the exception of the code syntax losing its color.
Does anyone know a way to have my pasted HTML include the colored R code?

Installing Prism to Ghost should enable syntax highlighting for multiple languages, including R and html
For the install instructions, follow this guide:
http://blog.davebalmer.com/adding-syntax-highlighting-to-ghost/

Related

IDE with LaTeX and R support: Inline output in .Rmd notebooks and weaving LaTeX document with R code

I'm trying to improve my workflow when working with R and generating documentation. I've been going between TeXStudio, JupyterLab and RStudio for a while, and I'm trying to improve my workflow. TeXStudio has limited R support, and RStudio limited support for LaTeX.
VS Code has support for multiple languages, including R and LaTeX. The fact that it can run both Jupyter notebooks, R notebooks, and LaTeX, and has plugins for other languages as well, makes it seem desirable. However, I am unable to find documentation on how to configure it to work with R and LaTeX code in the same file. In addition, I am unable to configure R notebooks to allow inline code execution output.
However, I am unable to (a) set up code execution output under the code for .Rmd notebooks, and (b) I can't figure out how to weave .Rnw (R/LaTeX) documents with Sweave/knitr.
I'm trying to find an IDE that would include features like:
Markdown, code and code execution output in the same document
Auto R and LaTeX code completion
Automatic display of R function documentation
Spell check
Simple R console access
Compile .Rnw
Syntax highlighting for both R code and LaTeX code
I am, primarily, requesting ways to configure VS Code, or, secondly, way to configure another IDE that can meet my requirements. A tutorial on this would be much appreciated.
After a bit of digging around, I found that VS Code does nearly all the things I need.
Auto R and LaTeX code completion, Display of R function documentation in a tab in VS Code, Simple R console access, and Syntax highlighting for both R code and LaTeX code:
The R and LaTeX Workshop extensions, will provide highlighting and autocompletion of code in both languages. By installing R, you can easily open a session in a terminal window in VS Code, and from there open documentation inside VS Code.
Spell check
Code Spell Checker offers spell check for multiple languages. Install the extension and any desired dictionaries, and set the langauges you want to be included in the extension settings.
Compile .Rnw files
Turns out LaTeX Workshop can actually do this by default.
Markdown, code and code execution output in the same document
This is the only thing VS Code doesn't do as far as I can tell. It can compile .Rmd files, however, but the output can only be seen in the compiled PDF. I consider this less important, since I can use Jupyter notebooks instead.

pandoc latex template

I have found this latex template,
http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/ThesisStyle/
which is perfect for my thesis. I am currently writing it directly in Latex with TexStudio, and playing around with the template directly is easy.
I am however switching to RStudio and wiriting it as a RNotebook, as I need to be able to easily produce docx versions of it (or other formats).
I already produced a Rmd version which works perfectly as a html/docx, but the pdf it produces (and i tried bookdown, thesisdown, oxfordown etc..) is never as good looking as the template above.
Is there a way to "extract" a template from the latex template in the link, which can be used for the pandoc conversion in RStudio? How?
(i am quite a newbie so please try with an easy accessible answer!)

How to use inline code in markdown in Jupyter with R

How to use inline code in markdown in Jupyter with R?
CODE CELL
n <- 8
MARKDOWN CELL
The Number is {{n}}
What would be the correct syntax in Jupyter Markdown for R? Is it even possible?
In case you haven't done it already, you might want to give the python markdown extension a shot, that adds the markdown inline code functionality for Python to Jupyter notebooks. On their github they claim:
The Python Markdown extension allows displaying output produced by the current kernel in markdown cells. The extension is basically agnostic to the kernel language, however most testing has been done using Python.
Installation instructions are on the github page of the nbextensions. Make sure you'll enable the python markdown extension using a jupyter command or the extension configurator.
Calling variables then should work inside a markdown cell with the {{var-name}} syntax that you've already given (described in the readme of the corresponding github page (linked in the wiki)).
If this doesn't help, you might want to join the discussion of the corresponding issues in the issue trackers for ipython and jupyter.

Syntax highlight in R Sweave

I am fairly new to doing report with R Sweave and know the very basic applications of Latex. And I have been asked to produce some statistical reports. The R markdown is great and simple, and by default it has really nice syntax frame and grey background and syntax highlights, however, it is quite limited in terms of other type setting, not really optimal when you want to produce lengthy reports. Then I am switching to use R Sweave in R studio.
I basically want the same after-effect similar to R markdown in the Sweave. What are the easiest ways to do it? I have previously read the following post discussing:
Sweave syntax highlighting in output. And I have tried reading those package pdf, but have no clues what they are talking about, as they seem to assume readers have prior knowledges about the rendering process.
i have checked them out, but I seem to get stuck in making it to work. Can anyone tell me step by step on how to set it up (such as what to include in preamble), if possible can you kindly upload a simple Rnw file with a demonstration?
Thank!
If you use knitr rather than Sweave, you'll get syntax highlighting. It's probably possible to do it in Sweave, but knitr makes it easier.
Go to your Tools | Global Options | Sweave menu (or the similar one in Project Options) in RStudio, and choose to Weave Rnw files using knitr.
The two systems are very similar, but knitr is generally preferable these days.

Syntax highlighting for Python chunks does not work

I'm trying to create notebooks in which I present the same algorithm written in R and Python. I can easily integrate the R and Python code in a Rmd file and then create a HTML output using the 'Knit HTML' button in RStudio. However the Python code is always displayed without syntax highlighting (not like in the example at https://github.com/yihui/knitr-examples/blob/master/023-engine-python.md). I have Andre Simon's highlight software installed and functioning on my computer (MacBook Pro Retina, MacOS X 10.9).
Currently, I have the following libraries installed in R: markdown 0.6.4, knitr 1.5.15, highr 0.3.1.
Any idea what could be the problem? Thanks for your help!.
That is specific to the RStudio Markdown render, which did not enable syntax highlighting for code blocks that are not R or C++. RStudio uses highlight.js, and you can use your own version of highlight.js to highlight Python code. Or use other Markdown converters such as Pandoc.

Resources