使用 RInside/Rcpp 从 C++ 调用 R 图 [英] Call R plots from c++ using RInside/ Rcpp
问题描述
是否可以从 C++ 调用绘图函数?目前,当我尝试这样做时,ubuntu 终端会冻结一段时间(可能是创建 3d 绘图然后旋转完整 360 度的持续时间)然后解冻,而不会弹出新窗口.这是预期的行为还是我做错了什么?如何使用 rinside 和 rcpp 从 C++ 中运行绘图(R 图形)?
Is it possible to call the plot functions from the c++ ? Currently when I try to do that, the ubuntu terminal sort of freezes for sometime ( may be the duration for which the 3d plot would be created and then rotated for a full 360 degrees) and then unfreezes, without ever popping a new window. Is this the expected behavior or is there something that I am doing wrong ? How can I get the plots ( R graphics ) to run from within c++ using rinside and rcpp ?
谢谢
-埃贡
推荐答案
是的,Rcpp 包中有一个工作示例.查看examples/
目录下的functionCallback/newApiExample.r
文件.
您可能需要尝试使用 sleep()
来保持"绘图片刻,或者绘图到文件然后显示文件.这一切都取决于,但你提供的细节很少.
Yes, there is a working examples in the Rcpp package. Look at the file functionCallback/newApiExample.r
in the examples/
directory.
You may need to experiment with sleep()
to 'hold' the plot for a moment, or plot to a file and then have the file displayed. It all depends but you gave little detail.
这篇关于使用 RInside/Rcpp 从 C++ 调用 R 图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!