Jupyter 中 R 中的 Magic %% 命令

Chr*_*ris 4 r jupyter jupyter-notebook jupyter-irkernel

如何在 Jupyter 中运行 R 中的 %%magic?

%%javascript
IPython.OutputArea.auto_scroll_threshold = 99999;
Run Code Online (Sandbox Code Playgroud)

较长输出的自动滚动功能非常烦人,因为我有几个函数和脚本会输出大量输出。

上面的 Javascript 在 python 笔记本中运行良好,但在 R 笔记本中则不行。

当我在 R 中运行 %% magic 命令时,它会吐出:

Error in parse(text = x, srcfile = src): <text>:1:1: unexpected SPECIAL
1: %%
Run Code Online (Sandbox Code Playgroud)

有什么建议么?


根据这篇文章disable_autoscroll.py,可以将该Javascript放入profile_dir/static/js/custom.js文件中。请告诉我,Windows 机器上的 profile_dir 在哪里?

我发现:c:/Anaconda2/Lib/site-packages/notebook/static/custom/custom.js但那是中心的 custom.js 文件。


参考:

长输出的自动滚动应该可以在 UI 中配置

Jan*_*ins 5

在我的笔记本电脑的 anaconda 安装中,该custom.js文件位于%USERPROFILE%\.jupyter\custom\custom.js.

对于“魔法”:魔法是Python内核的东西,而不是笔记本。R 内核没有实现魔法系统,因此这些不起作用。如上所述,用于您IRdisplay::display_javascript('IPython.OutputArea.auto_scroll_threshold = 99999;')用例。