有没有办法用R做Jupyter细胞魔术 [英] Is there a way to do Jupyter cell magic with R

查看:63
本文介绍了有没有办法用R做Jupyter细胞魔术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows 8笔记本电脑(64位)上安装了Jupyter和R.

I have installed Jupyter and R on my Windows 8 laptop (64bit).

如何在运行R内核的Jupyter笔记本中运行魔术命令.

How do I run magic commands in a Jupyter notebook running with the R kernel.

示例:我想运行例如

%%latex
\sqrt{2}

但不是格式化数学,而是返回:

but instead of formatted math this returns:

Error in parse(text = x, srcfile = src): <text>:1:1: unexpected SPECIAL
1: %%
    ^

这些函数的文档有些稀疏,并且很多内容尚未从IPython文档中进行更新.也许此功能不适用于r内核.

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.

推荐答案

魔术系统特定于IPython内核,并且在R内核中不存在.当前尚无计划集成这样的系统(=我们或多或少决定不在IRkernel中启动魔术系统).

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).

如果要显示r代码中的markdown(或html/images/...),则可以使用IRdisplay软件包提供的功能,例如:

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}$")

这篇关于有没有办法用R做Jupyter细胞魔术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆