twosigma / beakerx

Beaker Extensions for Jupyter Notebook
http://BeakerX.com
Apache License 2.0
2.8k stars 382 forks source link

Infinite loop in R "step()" #1612

Closed aolney closed 9 years ago

aolney commented 9 years ago

Executing this code for a linear model

fullnoint <- lm( SGAIN ~ L.SECONDS + LOCUS + ATTPRE + AGENT + EFFORT + GMRT + ACT, data = d2) 
step(fullnoint)

Causes an infinite loop (or waits forever)

Strangely if I reduce the number of variables so that the output is smaller, there is no infinite loop.

Also, the current behavior puts about 42 lines into the cell output, then puts ~14 lines into stdout, then truncates the rest. The command works fine in R 3.2.0.

If we force a different processing of the output by wrapping the call:

capture.output(step(fullnoint))

Then there is no infinite loop, but the output text isn't as pretty.

Version is beaker-notebook-v1.2.1-0-g7dc8ced-windows

scottdraves commented 9 years ago

thanks for the bug report, can you provide a more complete example that reproduces the problem?

aolney commented 9 years ago

Sure thing, this can be replicated with the built in mtcars dataset:

fullnoint <- lm( mpg ~ cyl + disp + hp + drat + wt + qsec + vs, data = mtcars) 
step(fullnoint)

As before there are 41 or 42 lines in the output cell, about 11 lines in stdout, and the rest are truncated.

What seems to work best as a workaround is actually to call capture.output() twice, like so:

capture.output()
fullnoint <- lm( mpg ~ cyl + disp + hp + drat + wt + qsec + vs, data = mtcars) 
capture.output(step(fullnoint))

I found that sometimes (like if I reboot the computer) that just having the second capture.output() wasn't enough, like it needed to be "initialized" somehow.

scottdraves commented 9 years ago

Thanks. I believe this has already been fixed. On 1.2.1 I can reproduce the problem, and on current master it works fine and I get this: screen shot 2015-05-14 at 4 24 08 pm

We fixed R to use the newer and better stdout mechanism. LMK if this doesn't look right.

aolney commented 9 years ago

OK, building from master fixed for me (version: master-0-g3e4a523)

I also downgraded R 3.2.0 to 3.1.0 to follow the windows build instructions precisely

Some very nice UI improvements in the master branch!

scottdraves commented 9 years ago

xlnt thanks for the followup. should work with R 3.2. In fact you don't have to add it to PATH anymore those instructions are a bit out of date, so I removed that part thanks for the tip.

glad you like it, there are more coming :)