我想从C ++代码运行R脚本。 [英] I want to run R script from C++ code.

查看:175
本文介绍了我想从C ++代码运行R脚本。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R does not  get compiled into intermediate code. Can any one help on how to integrate R with C++.





我尝试了什么:



尝试运行示例代码以从R脚本调用方法。链接器错误失败。



What I have tried:

Tried running sample code to call a method from R script. Failed with linker errors.

推荐答案

我们可以用C ++代码调用R脚本,如下所示,



#includestdafx.h

#include< iostream>

使用命名空间std;



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

cout<<Before<< endl;

system(C:\\\\ \\Program Files \\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\



返回0;

}



rscript是执行的命令test_script.R。
We can call a R script from C++ code as below,

#include "stdafx.h"
#include <iostream>
using namespace std;

int main(int argc, char **argv) {
cout<<"Before"<<endl;
system("C:\\\"Program Files\"\\R\\R-3.3.2\\bin\\rscript C:\\R-Scripts\\test_script.R");

return 0;
}

rscript is the command that executes the test_script.R.


这篇关于我想从C ++代码运行R脚本。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆