title: R script does not run in RStudio, but runs in the original console?
body: <p>These days, I have a problem with R and RStudio. The R script cannot run in RStudio, it often is interrupted. But it can successfully run in the original console. Here is the script:</p>
  
  <pre><code>library(MASS)
  simulation &lt;- function(index) { 
  n = 800  #100 200 400 800 1600 3200
   p = 0.5 * n  #0.5*n 0.8*n 1.2*n
    delta = 0.5  #0.5
    k0 = 1
    y = array(0, dim = c(p, n))
    # simulation1 r=3
    # ---------------------------------------------------------
    r = 4
    A = array(runif(p * r, min = -1, max = 1), dim = c(p, r))
    x = array(0, dim = c(r, n))  #x = array(0, dim = c(p, n)) 
    epsilon = array(t(mvrnorm(n, mu = rep(0, p), Sigma = diag(1, p, p))), 
                    dim = c(p, n))
    e = array(t(mvrnorm(n, mu = rep(0, r), Sigma = diag(1, r, r))), dim = c(r, 
                                                                            n))
    Pi = diag(c(0.6, -0.5, 0.3, 0.6), r, r)
    for (i in 2:n) {
      x[, i] = Pi %*% x[, i - 1, drop = FALSE] + e[, i]
    }
    A[, 2] = A[, 2]/p^(delta/2)  # weak factor
    y1 = A %*% x + epsilon
    y = t(scale(t(y1), center = T, scale = FALSE))
    Mhat = array(0, dim = c(p, p))
    for (i in 1:k0) {
      covk = y[, (i + 1):n, drop = FALSE] %*% t(y[, 1:(n - i), drop = FALSE])/(n - 
                                                                                 i)
      Mhat = Mhat + covk %*% t(covk)
    }
    R = p/2
    ratio = array(0, dim = c(R, 1))
    temp = eigen(Mhat)
    value = temp$values
    vector = temp$vectors
    for (i in 1:R) {
      ratio[i] = value[i + 1]/value[i]
    }
    plot(ratio, type = "l")
    rhat1 = which.min(ratio)
    Ahat1 = vector[, 1:rhat1, drop = FALSE]
    # two step
    ystar = y1 - Ahat1 %*% t(Ahat1) %*% y1
    ystar = t(scale(t(ystar), center = T, scale = FALSE))
    Mhatstar = array(0, dim = c(p, p))
    for (i in 1:k0) {
      covk = ystar[, (i + 1):n, drop = FALSE] %*% t(ystar[, 1:(n - i), 
                                                          drop = FALSE])/(n - i)
      Mhatstar = Mhatstar + covk %*% t(covk)
    }
    temp1 = eigen(Mhatstar)
    valuestar = temp1$values
    vector1 = temp1$vectors
    ratiostar = array(0, dim = c(R, 1))
    for (i in 1:R) {
      ratiostar[i] = valuestar[i + 1]/valuestar[i]
    }
    plot(ratiostar, type = "l")
    rhat2 = which.min(ratiostar)
    # Ahat2 = vector1[, 1:rhat2, drop = FALSE]
    rhat = rhat1 + rhat2
    # Ahat = cbind2(Ahat1, Ahat2)
    return(rhat)
  }
  result=replicate(200,simulation())
  </code></pre>
  
  <p>The program is often interrupted. I do not know why.</p>
  
  <p>My desktop is : win7
  RStudio version :0.98.426
  The log file is :</p>
  
  <pre><code>15 Oct 2013 11:02:50 [rsession-Administrator] WARNING Abort requested; LOGGED FROM: bool session::connection::checkForAbort(boost::shared_ptr&lt;session::HttpConnection&gt;, boost::function&lt;void()&gt;) C:\Users\Administrator\rstudio\src\cpp\session\http\SessionHttpConnectionUtils.cpp:146
  15 Oct 2013 11:03:00 [rsession-Administrator] ERROR r error 5 (R symbol not found) [symbol (option)=ggvis.renderer]; OCCURRED AT: T r::options::getOption(const std::string&amp;, const T&amp;) [with T = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;] C:\Users\Administrator\rstudio\src\cpp\r\include/r/ROptions.hpp:73; LOGGED FROM: T r::options::getOption(const std::string&amp;, const T&amp;) [with T = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;] C:\Users\Administrator\rstudio\src\cpp\r\include/r/ROptions.hpp:75
  </code></pre>