4

I installed R for use with Jupyter notebooks following the instructions here https://conda.io/docs/r-with-conda.html

This allowed me to create new notebooks using R as the language which is working fine.

But it's incredibly slow. I'm running some mixed models with the glmer command from lme4 and they are taking orders of magnitude longer. In rStudio I can calculate the model in 10-15 seconds but it takes over a few minutes in the Jupyter notebook.

Why is this? Is there a more efficient back end I should be pointing the notebook to?

Example of command cited above:

glmer(goalMet ~ relationToReminder * refresher * initial + (1 + scheduledDate | emailAddress), data=tasks, family="binomial", "control=glmer(optimizer="bobyqa"))
Aaron Springer
  • 233
  • 1
  • 9
  • Could you show a piece of sample code that is significantly slower in Jupyter? – uut Mar 15 '17 at 22:48
  • That is probably as good as it gets. I have been using jupyter notebook with python for about a year. Scripts run from the command prompt execute in a few seconds and a few minutes in the notebooks. I have also played a bit with R in jupyter notebooks. It does seem slow. But it is wonderful for making visual stories. One way that works is to do the number crunching in r or rstudio, save an rmd file and then import crunched numbers to do your final presentation in notebook. Not a one step process, but it works. – sconfluentus Mar 16 '17 at 01:36
  • Oh...and there does not seem to be a faster backend, it is a limit of the interpreter. – sconfluentus Mar 16 '17 at 01:37
  • @uut I've added an example command above. – Aaron Springer Mar 16 '17 at 22:10
  • @bethanyP I haven't noticed any major slowdown with Python3 which I've been using in Jupyter for a couple years. I guess it's possible that they are slower than command line and I've just never noticed. I mainly want to use notebooks because it allows me to easily save an analysis workflow because rStudio only has a poor history log – Aaron Springer Mar 16 '17 at 22:12
  • I have only used python 2.7 in the notebooks. I have noticed that it is slow, but I use it in a data intensive way, which might exacerbate the differences between Python3 and 2.7. I have found now way of speeding it up...but I feel like it is worth the tradeoff in how easy it is to work with cells to build and test scripts. – sconfluentus Mar 16 '17 at 22:16
  • @AaronSpringer I'll see if I can reproduce the slowdown. In the meanwhile, perhaps you could try [using rpy2 to start a R cell inside a iPython notebook](http://stackoverflow.com/questions/39008069/r-and-python-in-one-jupyter-notebook/41889995#41889995) (instead of a Jupyter notebook bound to the R kernel) and see if the slowdown persists? Also could you try repressing the output by setting the model to a variable? i.e. `model <- glmer(...)` instead of `glmer(...)`. I suspect invoking the `print` statement implicitly might be slowing things down. – uut Mar 18 '17 at 00:12
  • I found Anaconda's R to be slower than one from http://r-project.org – Kirill Voronin Nov 21 '18 at 11:06

0 Answers0