6

I am using R 3.0.2 in Windows 7 64 bit. After running simulations with an output greater than about 100000 in length, if I use the mouse scroll wheel in the R console, Windows freezes indefinitely.

I once left it sitting for over a week with no response. Forcing shutdown is the only way out, and it does not register in Windows event log. I have tried to duplicate the issue in other programs, but it appears to occur only in R. I have tried several versions of R, uninstalled and reinstalled each, used several different computer mice and drivers, and even reinstalled Windows. Nothing has fixed the issue.

Some other common aspects that I can think of (but not yet certain are factors) are that

  1. the simulations typically print iteration numbers, etc to the console during the simulation (using flush.console() for instance), and

  2. memory use is high during (but not upon completion of) the simulation. Computer has 32GB RAM and two Intel Xeon E5-2687W CPUs (8-core, 3.1GHz).

An example that might cause this issue for me is:

    foo<-function(X, SD, N, sims){
    output<-vector("list")
    for(i in 1:sims){
        output[[i]]<-rnorm(N, X, SD)
        flush.console()
        cat(paste("Iteration", i, ":", "\n",
            "mean = ", round(mean(output[[i]]),1), "\n",
            "sd   = ", round(sd(output[[i]]), 1), "\n"))
    }
    return(output)
    }

    result<-foo(X=20, SD=2, N=100, sims=100) # but increase N or sims to > 100000

    # Now used the mouse scroll wheel in the R console.  Computer freezes.
    # Can also do rm(list=ls()) after the simulation, then use scroll wheel... Computer still freezes.
Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
  • 1
    Are you running RStudio? If not, try it to see if the problem goes away. – Matthew Lundberg Feb 04 '14 at 00:05
  • 1
    @Matthew I haven't tried it in R studio, but will check into it and let you know. Still hope to figure the issue out in R itself though. – user3267754 Feb 04 '14 at 00:37
  • 1
    When it comes to looking at an output I have found R as displayed by R-cran's base version to be buggier than displaying in tinn-R, particularly if you try to scroll while code is still running. Tinn-R also is just much easier to use because it displays code side by side interpreter and makes it easy to send the interpreter code. Same thing is true for R-Studio. One annoyingly practical piece of advice is to stop scrolling through large outputs! If you really need to look at it save the output and open it up as a text file. One final note is any program will freeze when you run out of memory. – Michael Feb 04 '14 at 05:27
  • Not using the scroll wheel is harder in practice for me than it sounds as it's easy to forget about when engaged in an analysis, etc. Also, the issue still occurs in RStudio. Not sure about Tinn-R yet. Despite occurring only in R, it's still looking more and more like an issue with my computer rather than an issue with R. I will update if I figure anything out. Thanks for the suggestions. – user3267754 Feb 07 '14 at 02:19
  • 1
    It works fine for me with `sims=1000000`. I haven't tried with `N=1000000` because printing 1000000 lines of output is silly. A workaround would be to print every k iterations where k << N. – Hong Ooi Feb 10 '14 at 02:20
  • 1
    Just wanted to say that I also frequently experience this very annoying problem with Rgui (is Rgui what you refer to with 'console'? Or are you running R in a command window?) I had not realized that it is associated with having a session with many lines; but that fits my experience; that is helpful to know. Does it help if you change the buffer or lines option in the Rgui settings? – Robert Hijmans Mar 09 '14 at 05:39
  • @RobertH Yes, I was referring to Rgui. Changing the buffer or lines options doesn't seem to make a difference, and I have yet to find any other way to fix it. Interestingly, I have NOT been able to reproduce the issue in tinn-R, but I'm just not very fond of that interface. Thanks for your comment by the way. It's good (and bad) to find I'm not the only person experiencing this. – user3267754 Mar 17 '14 at 18:22

1 Answers1

0

Your code runs smooth in my computer with both (Rgui.exe and Tinn-R + Rterm.exe).

Windows 7 (64 bit) and R version 3.0.2 Patched (2013-10-08 r64039).

See the output below:

R version 3.0.2 Patched (2013-10-08 r64039) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R é um software livre e vem sem GARANTIA ALGUMA.
Você pode redistribuí-lo sob certas circunstâncias.
Digite 'license()' ou 'licence()' para detalhes de distribuição.

R é um projeto colaborativo com muitos contribuidores.
Digite 'contributors()' para obter mais informações e
'citation()' para saber como citar o R ou pacotes do R em publicações.

Digite 'demo()' para demonstrações, 'help()' para o sistema on-line de ajuda,
ou 'help.start()' para abrir o sistema de ajuda em HTML no seu navegador.
Digite 'q()' para sair do R.

> foo<-function(X, SD, N, sims){
+     output<-vector("list")
+     for(i in 1:sims){
+         output[[i]]<-rnorm(N, X, SD)
+         flush.console()
+         cat(paste("Iteration", i, ":", "\n",
+             "mean = ", round(mean(output[[i]]),1), "\n",
+             "sd   = ", round(sd(output[[i]]), 1), "\n"))
+     }
+     return(output)
+     }
> 
>     result<-foo(X=20, SD=2, N=100, sims=100) # but increase N or sims to > 100000
Iteration 1 : 
 mean =  20.1 
 sd   =  2 
Iteration 2 : 
 mean =  20 
 sd   =  2 
Iteration 3 : 
 mean =  19.9 
 sd   =  2 
Iteration 4 : 
 mean =  19.9 
 sd   =  1.9 
Iteration 5 : 
 mean =  19.5 
 sd   =  2.1 
Iteration 6 : 
 mean =  20 
 sd   =  2.2 
Iteration 7 : 
 mean =  20.2 
 sd   =  2.2 
Iteration 8 : 
 mean =  20 
 sd   =  1.8 
Iteration 9 : 
 mean =  19.5 
 sd   =  2 
Iteration 10 : 
 mean =  20.1 
 sd   =  2.1 
Iteration 11 : 
 mean =  19.8 
 sd   =  2 
Iteration 12 : 
 mean =  20 
 sd   =  2 
Iteration 13 : 
 mean =  20 
 sd   =  1.8 
Iteration 14 : 
 mean =  19.9 
 sd   =  1.8 
Iteration 15 : 
 mean =  20.2 
 sd   =  2 
Iteration 16 : 
 mean =  20.2 
 sd   =  1.8 
Iteration 17 : 
 mean =  20.5 
 sd   =  2.2 
Iteration 18 : 
 mean =  20 
 sd   =  1.9 
Iteration 19 : 
 mean =  19.8 
 sd   =  1.8 
Iteration 20 : 
 mean =  19.9 
 sd   =  2.2 
Iteration 21 : 
 mean =  20.2 
 sd   =  2 
Iteration 22 : 
 mean =  19.7 
 sd   =  1.8 
Iteration 23 : 
 mean =  19.8 
 sd   =  2 
Iteration 24 : 
 mean =  19.8 
 sd   =  1.9 
Iteration 25 : 
 mean =  19.9 
 sd   =  2.1 
Iteration 26 : 
 mean =  20.3 
 sd   =  2.1 
Iteration 27 : 
 mean =  19.6 
 sd   =  2 
Iteration 28 : 
 mean =  20 
 sd   =  2.1 
Iteration 29 : 
 mean =  20 
 sd   =  2.2 
Iteration 30 : 
 mean =  19.9 
 sd   =  1.7 
Iteration 31 : 
 mean =  19.9 
 sd   =  1.8 
Iteration 32 : 
 mean =  19.8 
 sd   =  1.9 
Iteration 33 : 
 mean =  20.1 
 sd   =  2.1 
Iteration 34 : 
 mean =  20.3 
 sd   =  2.2 
Iteration 35 : 
 mean =  20.2 
 sd   =  2 
Iteration 36 : 
 mean =  20.1 
 sd   =  2 
Iteration 37 : 
 mean =  19.8 
 sd   =  2.1 
Iteration 38 : 
 mean =  20 
 sd   =  2 
Iteration 39 : 
 mean =  20.1 
 sd   =  1.9 
Iteration 40 : 
 mean =  20.1 
 sd   =  2 
Iteration 41 : 
 mean =  19.8 
 sd   =  2.1 
Iteration 42 : 
 mean =  19.9 
 sd   =  2 
Iteration 43 : 
 mean =  19.8 
 sd   =  1.8 
Iteration 44 : 
 mean =  20.1 
 sd   =  1.7 
Iteration 45 : 
 mean =  20.1 
 sd   =  1.8 
Iteration 46 : 
 mean =  20.1 
 sd   =  1.9 
Iteration 47 : 
 mean =  20 
 sd   =  2.2 
Iteration 48 : 
 mean =  19.8 
 sd   =  1.9 
Iteration 49 : 
 mean =  19.9 
 sd   =  2.1 
Iteration 50 : 
 mean =  19.7 
 sd   =  2 
Iteration 51 : 
 mean =  19.9 
 sd   =  2 
Iteration 52 : 
 mean =  20.5 
 sd   =  2 
Iteration 53 : 
 mean =  20 
 sd   =  2 
Iteration 54 : 
 mean =  20.3 
 sd   =  1.9 
Iteration 55 : 
 mean =  19.9 
 sd   =  1.9 
Iteration 56 : 
 mean =  20.1 
 sd   =  2.1 
Iteration 57 : 
 mean =  20.3 
 sd   =  2.2 
Iteration 58 : 
 mean =  19.8 
 sd   =  2.3 
Iteration 59 : 
 mean =  20.2 
 sd   =  2 
Iteration 60 : 
 mean =  19.6 
 sd   =  2.1 
Iteration 61 : 
 mean =  19.9 
 sd   =  1.9 
Iteration 62 : 
 mean =  20.1 
 sd   =  1.9 
Iteration 63 : 
 mean =  20.1 
 sd   =  2.3 
Iteration 64 : 
 mean =  19.8 
 sd   =  2.1 
Iteration 65 : 
 mean =  20 
 sd   =  2 
Iteration 66 : 
 mean =  19.7 
 sd   =  1.9 
Iteration 67 : 
 mean =  20.1 
 sd   =  2.1 
Iteration 68 : 
 mean =  20.2 
 sd   =  2 
Iteration 69 : 
 mean =  20.1 
 sd   =  2 
Iteration 70 : 
 mean =  20.2 
 sd   =  2.1 
Iteration 71 : 
 mean =  20.1 
 sd   =  2 
Iteration 72 : 
 mean =  20.2 
 sd   =  2.1 
Iteration 73 : 
 mean =  20.1 
 sd   =  2 
Iteration 74 : 
 mean =  20 
 sd   =  2 
Iteration 75 : 
 mean =  19.8 
 sd   =  2.2 
Iteration 76 : 
 mean =  20.1 
 sd   =  2.2 
Iteration 77 : 
 mean =  20.2 
 sd   =  1.5 
Iteration 78 : 
 mean =  20.1 
 sd   =  2.2 
Iteration 79 : 
 mean =  20.2 
 sd   =  2.1 
Iteration 80 : 
 mean =  20.1 
 sd   =  2.1 
Iteration 81 : 
 mean =  20 
 sd   =  1.8 
Iteration 82 : 
 mean =  20.4 
 sd   =  2.1 
Iteration 83 : 
 mean =  20.1 
 sd   =  1.9 
Iteration 84 : 
 mean =  20.1 
 sd   =  2.1 
Iteration 85 : 
 mean =  20.2 
 sd   =  2 
Iteration 86 : 
 mean =  19.8 
 sd   =  2.1 
Iteration 87 : 
 mean =  20.1 
 sd   =  2 
Iteration 88 : 
 mean =  19.9 
 sd   =  2.1 
Iteration 89 : 
 mean =  20 
 sd   =  1.9 
Iteration 90 : 
 mean =  19.8 
 sd   =  2.2 
Iteration 91 : 
 mean =  19.9 
 sd   =  2 
Iteration 92 : 
 mean =  20 
 sd   =  2 
Iteration 93 : 
 mean =  19.9 
 sd   =  2.2 
Iteration 94 : 
 mean =  19.8 
 sd   =  1.8 
Iteration 95 : 
 mean =  19.7 
 sd   =  1.8 
Iteration 96 : 
 mean =  20.6 
 sd   =  1.8 
Iteration 97 : 
 mean =  20.1 
 sd   =  2 
Iteration 98 : 
 mean =  19.8 
 sd   =  1.9 
Iteration 99 : 
 mean =  19.9 
 sd   =  1.9 
Iteration 100 : 
 mean =  19.8 
 sd   =  1.8 
> 
jcfaria
  • 312
  • 3
  • 14