用于littler或Rscript的外部图形设备 [英] External graphical device for littler or Rscript
问题描述
我真的很喜欢littler对于使用R的脚本来说非常棒。但是我不知道如何使用外部图形设备la gnuplot(例如使用Octave)。
我能够产生所需的图形,但我必须使用Sys.sleep,但我不想这样做,因为我想以交互方式关闭自己,或者更好地继续执行脚本而不关闭该设备。
I really like littler is really great for scripting using R. But i don't how to use external graphics device a la gnuplot (for example using Octave). I'm able to produce the desired graph but i have to use Sys.sleep and i don't want to do so, because i want to close it my self in an interactive way or better continue the script without closing the device.
到目前为止,这是我的代码的样子:
So far this is what my code looks like :
#!/usr/bin/env r -t
suppressMessages(require(Cairo))
CairoX11()
plot(rnorm(1000), pch = 19)
Sys.sleep(50)
# some code without closing the graphics window
我的问题是:你知道一种方法来实现吗?
My question is : Do you know a way to achieve that ?
任何提示,文档,链接或代码都将被赞赏
Any hint, document, link or code will be appreciated
推荐答案
除了约翰的建议外,你可以明确地调用其中的一个GUI包来创建一个新的框架(或窗口),然后显示剧情。这将保持在屏幕上,直到用户(或外部事件)终止该窗口。
Besides John's suggestion, you could be explicit and invoke one of the GUI packages to bring up a new 'frame' (or 'window') that then shows the plot. That will remain on-screen until the user (or an external event) terminates that window.
tcltk 包可以与 tkrplot 包;这是最便携的。 RGtk2 更现代但更难在Windows上安装/使用,因为Gtk2并不完全是原生的。还有更多的---在这里和其他地方搜索R图形用户界面。
The tcltk package can be used along with the tkrplot package; this is the most portable. RGtk2 is more modern but harder to install / use on Windows as Gtk2 is not exactly native there. There is more---search for R GUIs here and on other places on the intertubes.
这篇关于用于littler或Rscript的外部图形设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!