【发布时间】:2018-06-29 23:48:15
【问题描述】:
在 C++ 中,我们可以将变量声明为引用。
int a = 10;
int& b = a;
如果我们设置b=15,a 也会改变。
我想在 Rcpp 中做类似的事情。
List X = obj_from_R["X"];
IntegerVector x_i = X[index];
x_i = value;
我想从 R 中更新一个名为 X 的对象,方法是在其向量之一中插入一个值。上面的代码不起作用,所以我尝试了这个:
IntegerVector& x_i = X[index];
并收到一个错误。
error: non-const lvalue reference to type 'IntegerVector'
(aka 'Vector<13>') cannot bind to a temporary of type 'Proxy' (aka 'generic_proxy<19>')
【问题讨论】: