Jupyter 中 R 中的 Magic %% 命令

Magic %% commands in R inside Jupyter

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

%%javascript
IPython.OutputArea.auto_scroll_threshold = 99999;

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

上面的 Javascript 在 python 笔记本中工作正常,但在 R 笔记本中不行。

当我 运行 R 中的 %% 魔法命令时,它会吐出:

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

有什么建议吗?


根据此 post 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 文件。


参考文献:

Auto-scrolling of long output should be configurable in the UI

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

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