This issue has been submitted and answered previously in the repository rmarkdown . Here I am only trying to explain the technical reason why this did not work.
On the help page ?neuralnet::plot.nn:
Usage
plot(x, rep = NULL, x.entry = NULL, x.out = NULL,
....
Arguments
...
rep repetition of the neural network. If rep="best", the repetition
with the smallest error will be plotted. If not stated all repetitions
will be plotted, each in a separate window.
From the source code (v1.33):
> neuralnet:::plot.nn
function (x, rep = NULL, x.entry = NULL, x.out = NULL, radius = 0.15,
....
{
....
if (is.null(rep)) {
for (i in 1:length(net$weights)) {
....
grDevices::dev.new()
plot.nn(net, rep = i,
....
}
}
, .... . , rep, neuralnet:::plot.nn . knitr,
- , (
dev.control(displaylist = 'enable')); - knitr ; , , knitr. , .
neuralnet, drop dev.new() , , , .
if (interactive()) grDevices::dev.new()
, dev.new() , , , , . R / ( , , x11() quartz()), , .
interactive(), R, , ( , ) .