I think you can tweak the rgl hook a little bit, e.g.
knit_hooks$set(rgl = function(before, options, envir) {
# if a device was opened before this chunk, close it
if (before && rgl.cur() > 0) rgl.close()
hook_rgl(before, options, envir)
})
Regards,
Yihui
--
Yihui Xie <
xiey...@gmail.com>
Phone:
515-294-2465 Web:
http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA