I have installed Jupyter and R on my Windows 8 laptop (64bit).
How do I run magic commands in a Jupyter notebook running with the R kernel.
Example: I would like to run e.g.
%%latex
\sqrt{2}
but instead of formatted math this returns:
Error in parse(text = x, srcfile = src): <text>:1:1: unexpected SPECIAL
1: %%
^
The documentation for these functions is somewhat sparse and a lot of it has not been updated from the IPython documentation. Perhaps this functionality is not intended with r kernels.
The magic system is specific to the IPython kernel and does not exist in the R kernel. Currently there are no plans to integrate such a system (= we more or less decided not to start a magic system in IRkernel).
If you want to display markdown (or html/images/...) from r code, you can use the functions provided by the IRdisplay package, like:
library(IRdisplay)
display_markdown("**Strong Text**\n\nA formula: $\\sqrt{x}$")
For Latex in Jupyter you do not need R magic. You can select cell type in the top panel with icons. Change "code" to "Markdown" and type:
$$
\sqrt{2}
$$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With