在指定目录中创建一个 PNG < /C>文件,如果从R直接运行,但使用RIN的C++调用,我不能复制相同的结果。(强)我可以用C++调用复制所有的基数图。只有格子和GGPUTS/的问题< /P>,r,plot,lattice,rcpp,rinside,R,Plot,Lattice,Rcpp,Rinside" /> 在指定目录中创建一个 PNG < /C>文件,如果从R直接运行,但使用RIN的C++调用,我不能复制相同的结果。(强)我可以用C++调用复制所有的基数图。只有格子和GGPUTS/的问题< /P>,r,plot,lattice,rcpp,rinside,R,Plot,Lattice,Rcpp,Rinside" />

使用RInside和Rcpp保存晶格图 我试图用RIN在C++中构建R应用程序。我想用代码将绘图保存为指定目录中的图像 png(filename = "filename", width = 600, height = 400) xyplot(data ~ year | segment, data = dataset, layout = c(1,3), type = c("l", "p"), ylab = "Y Label", xlab = "X Label", main = "Title of the Plot") dev.off() < >在指定目录中创建一个 PNG < /C>文件,如果从R直接运行,但使用RIN的C++调用,我不能复制相同的结果。(强)我可以用C++调用复制所有的基数图。只有格子和GGPUTS/的问题< /P>

使用RInside和Rcpp保存晶格图 我试图用RIN在C++中构建R应用程序。我想用代码将绘图保存为指定目录中的图像 png(filename = "filename", width = 600, height = 400) xyplot(data ~ year | segment, data = dataset, layout = c(1,3), type = c("l", "p"), ylab = "Y Label", xlab = "X Label", main = "Title of the Plot") dev.off() < >在指定目录中创建一个 PNG < /C>文件,如果从R直接运行,但使用RIN的C++调用,我不能复制相同的结果。(强)我可以用C++调用复制所有的基数图。只有格子和GGPUTS/的问题< /P>,r,plot,lattice,rcpp,rinside,R,Plot,Lattice,Rcpp,Rinside,我也使用了以下代码 myplot <- xyplot(data ~ year | segment, data = dataset, layout = c(1,3), type = c("l", "p"), ylab = "Y Label", xlab = "X Label", main = "Title of the Plot") trellis.device(device = "png", filename = "fi

我也使用了以下代码

myplot <- xyplot(data ~ year | segment, data = dataset, layout = c(1,3), 
                 type = c("l", "p"), ylab = "Y Label", xlab = "X Label",
                 main = "Title of the Plot")
trellis.device(device = "png", filename = "filename")
print(myplot)
dev.off()

myplot以下内容将晶格
xyplot
打印到png。这是一个最小的例子,作为一个变体完成 大约
冲洗样本11.cpp

#include <RInside.h>                    // for the embedded R via RInside
#include <unistd.h>

int main(int argc, char *argv[]) {

  // create an embedded R instance
  RInside R(argc, argv);               

  // evaluate an R expression with curve() 
  // because RInside defaults to interactive=false we use a file
  std::string cmd = "library(lattice); "
    "tmpf <- tempfile('xyplot', fileext='.png'); "  
    "png(tmpf); "
    "print(xyplot(Girth ~ Height | equal.count(Volume), data=trees)); "
    "dev.off();"
    "tmpf";
  // by running parseEval, we get the last assignment back, here the filename
  std::string tmpfile = R.parseEval(cmd);

  std::cout << "Can now use plot in " << tmpfile << std::endl;

  exit(0);
}
#包含//用于通过RInside的嵌入式R
#包括
int main(int argc,char*argv[]){
//创建一个嵌入式R实例
漂洗液R(argc,argv);
//使用曲线()计算R表达式
//因为RInside默认为interactive=false,所以我们使用一个文件
std::string cmd=“库(晶格);”

“tmpf下面将晶格
xyplot
打印到png。这是一个最小的示例,作为一个变体完成 大约
冲洗样本11.cpp

#include <RInside.h>                    // for the embedded R via RInside
#include <unistd.h>

int main(int argc, char *argv[]) {

  // create an embedded R instance
  RInside R(argc, argv);               

  // evaluate an R expression with curve() 
  // because RInside defaults to interactive=false we use a file
  std::string cmd = "library(lattice); "
    "tmpf <- tempfile('xyplot', fileext='.png'); "  
    "png(tmpf); "
    "print(xyplot(Girth ~ Height | equal.count(Volume), data=trees)); "
    "dev.off();"
    "tmpf";
  // by running parseEval, we get the last assignment back, here the filename
  std::string tmpfile = R.parseEval(cmd);

  std::cout << "Can now use plot in " << tmpfile << std::endl;

  exit(0);
}
#包含//用于通过RInside的嵌入式R
#包括
int main(int argc,char*argv[]){
//创建一个嵌入式R实例
漂洗液R(argc,argv);
//使用曲线()计算R表达式
//因为RInside默认为interactive=false,所以我们使用一个文件
std::string cmd=“库(晶格);”

“tmpf可能您需要一个虚拟x11设备来制作字体,请参阅有关
xvfb
和/或
[r]的问题。”xvfb
。我只是用这种方式创建了基本图。如果可以的话,用推特打我也有点粗鲁。我不欠你支持,只要我有时间,而且不麻烦,我就这么做。所以请不要这样做。@Dirkeddebuettel:对不起。我知道我肯定会得到你的回复。所以,我这么做的目的是希望能尽快得到回复r、 后来我意识到这不是一个好的行为,我不应该这样做。以后不再重复。非常感谢您的回答。:)也许您需要一个虚拟x11设备来制作字体,请参阅关于
xvfb
和/或
[r]的问题xvfb
。我只是用这种方式创建了基本图。如果可以的话,用推特打我也有点粗鲁。我不欠你支持,只要我有时间,而且不麻烦,我就这么做。所以请不要这样做。@Dirkeddebuettel:对不起。我知道我肯定会得到你的回复。所以,我这么做的目的是希望能尽快得到回复r、 后来我意识到这不是一个好的行为,我不应该这样做。以后我不会再重复了。非常感谢您的回复。:)