title: Plot neural net work
body: <p>I use RStudio. In order to plot neural network, I use the package <code>neuralnet</code> and function 'plot' to do the picture. But I find that every time, it will just show me a separated picture by Quartz rather than as in the plot field of RStudio. </p>
  
  <p>Furthermore, <code>plot</code> does not work under RMarkdown. </p>
  
  <p>Can anyone tell how to fix it? It seems I need to disable the Quartz from RStudio. Thanks</p>
  
  <p>The following is the code</p>
  
  <pre><code>    set.seed(500)
      library(MASS)
      data &lt;- Boston
      apply(data,2,function(x) sum(is.na(x)))
      index &lt;- sample(1:nrow(data),round(0.75*nrow(data)))
      train &lt;- data[index,]
      test &lt;- data[-index,]
      lm.fit &lt;- glm(medv~., data=train)
      summary(lm.fit)
      pr.lm &lt;- predict(lm.fit,test)
      MSE.lm &lt;- sum((pr.lm - test$medv)^2)/nrow(test)
      maxs &lt;- apply(data, 2, max) 
      mins &lt;- apply(data, 2, min)
      scaled &lt;- as.data.frame(scale(data, center = mins, scale = maxs-mins))
     train_ &lt;- scaled[index,]
     test_ &lt;- scaled[-index,]
     library(neuralnet)
     n &lt;- names(train_)
     f &lt;- as.formula(paste("medv ~", paste(n[!n %in% "medv"], collapse = " + ")))
     nn &lt;- neuralnet(f,data=train_,hidden=c(5,3),linear.output=T)
     plot(nn)
  </code></pre>