Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magic %% commands in R inside Jupyter

How do I run %%magic in R inside Jupyter?

%%javascript
IPython.OutputArea.auto_scroll_threshold = 99999;

The auto scroll feature on longer output is vastly annoying as I have several functions and scripts that spit out a lot of output.

The above Javascript works fine in python notebooks but not in R notebooks.

When I run the %% magic command in R, it barfs:

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

Any suggestions?


According to this post disable_autoscroll.py, it may be possible to put that Javascript into a profile_dir/static/js/custom.js file. Pray tell, where is the profile_dir on a Windows box?

I found: c:/Anaconda2/Lib/site-packages/notebook/static/custom/custom.js but that is the central custom.js file.


References:

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

like image 329
Chris Avatar asked Oct 14 '25 11:10

Chris


1 Answers

In my anaconda install of the notebook, the custom.js file is in %USERPROFILE%\.jupyter\custom\custom.js.

For the "magics": magics are a thing of the python kernel, not the notebook. The R kernel does not implement a magic system and so these don't work. As mentioned above, use IRdisplay::display_javascript('IPython.OutputArea.auto_scroll_threshold = 99999;') for your usecase.

like image 181
Jan Katins Avatar answered Oct 17 '25 02:10

Jan Katins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!