使用来自R的参数进行RInside调用

使用来自R的参数进行RInside调用,r,rcpp,rinside,R,Rcpp,Rinside,我试图将参数传递给一个exe文件,该文件包含RInside,并使用make编译 这段代码的灵感来自 第二,通过C++来将代码> > x>代码>和 y>代码>,这是从C++中编译成exe代码而不是在C++代码中声明的最好方式吗?我应该使用文件吗 编辑这是在尝试使用额外空间时出现的错误:候选人需要0个参数,提供1个 z = Rcpp::as<std::vector<double> >(rtest(x, y)); z=Rcpp::as(rtest(x,y)); 给予 C:

我试图将参数传递给一个
exe
文件,该文件包含
RInside
,并使用
make
编译

这段代码的灵感来自

<>第二,通过C++来将代码> > x>代码>和<代码> y>代码>,这是从C++中编译成exe代码而不是在C++代码中声明的最好方式吗?我应该使用文件吗


编辑这是在尝试使用额外空间时出现的错误:
候选人需要0个参数,提供1个

z = Rcpp::as<std::vector<double> >(rtest(x, y));
z=Rcpp::as(rtest(x,y));
给予

C:/Rtools/mingw_64/x86_64-w64-mingw32/include/C++/bits/stl_vector.h:264:7:注意:参数1从“”到常量分配器类型&{aka const std::allocator&}的转换未知
C:/Rtools/mingw_64/x86_64-w64-mingw32/include/C++/bits/stl_vector.h:253:7:注意:std::vector::vector()[带_Tp=double;_Alloc=std::allocator]
向量()
^
C:/Rtools/mingw_64/x86_64-w64-mingw32/include/C++/bits/stl_vector.h:253:7:注意:候选者需要0个参数,提供1个
make:**[:soorig]错误1


EDIT:这是我在
Makefile.win

中修改这些行后得到的错误编译的问题似乎是,Dirk和my的
g++
默认为C++11,而Rtools中的则不是。您可以通过更改
RInside
附带的
GNUmakefile
中定义
CXX
cxflags
的方式来修复此问题:

CXX :=      $(shell $(R_HOME)/bin/R CMD config CXX11) $(shell $(R_HOME)/bin/R CMD config CXX11STD)
CPPFLAGS := -Wall $(shell $(R_HOME)/bin/R CMD config CPPFLAGS)
CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R CMD config CXX11FLAGS)
或者,您可以删除C++11中的所有细节


至于如何提供输入数据:这实际上取决于是否要提供可能较长的向量。对于前一种情况,我将使用文件。

尝试添加一个额外的空间:
Rcpp::as(rtest(x,y))修改为
z=Rcpp::as(rtest(x,y))后仍会出现相同的错误可能首先分配给变量。或者尝试不使用该代码,确定您实际上可以使用RInside构建。顺便说一句,在Ubuntu 18.10上使用更新的g++例如g++8.2.0,你的代码可以很好地编译。你在Windows上的编译器版本是固定的。你需要找出它失败的原因。至于传递参数,这是将命令行参数传递给C程序的标准问题。有答案,但这与Rcpp或RInside无关。谢谢Ralf,我将检查今晚是否尝试替换Makefile.win中的这些行-因为我在windows上,我收到了此错误
g++.exe:error:=:没有这样的文件或目录生成:**[:soorig]错误1
更改GNUmakefile中的这些行会产生另一个错误:
注意:参数1从“”到“常量分配器类型&{aka const std::allocator&}”的转换未知。
下一行:
C:/Rtools/mingw_64/x86_64-w64-mingw32/include/C++/bits/stl_vector.h:253:7:注意:std::vector::vector()[with_Tp=double;_Alloc=std::allocator]vector()^
@gpier请添加
Makefile.win
以及您看到的问题错误消息。注释不足以提供此类信息。
z = Rcpp::as<std::vector<double> >(rtest(x, y));
C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/bits/stl_vector.h:264:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const allocator_type& {aka const std::allocator<double>&}'
C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/bits/stl_vector.h:253:7: note: std::vector<_Tp, _Alloc>::vector() [with _Tp = double; _Alloc = std::allocator<double>]
       vector()
       ^
C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/bits/stl_vector.h:253:7: note:   candidate expects 0 arguments, 1 provided
make: *** [<builtin>: soorig] Error 1
CXX :=      $(shell $(R_HOME)/bin/R CMD config CXX11) $(shell $(R_HOME)/bin/R CMD config CXX11STD)
CPPFLAGS := -Wall $(shell $(R_HOME)/bin/R CMD config CPPFLAGS)
CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R CMD config CXX11FLAGS)