[英]Access elements in a list in Rcpparmadillo?
I am working with Rcpparmadillo and get an question about how to reach the elements in list. 我正在与Rcpparmadillo合作,并遇到有关如何达到列表中元素的问题。
It is understandable to do that when I return the values to R, now I want to know how to do that in c++, in other words, the list generated from a function is still be referred in c++. 可以理解的是,当我将值返回到R时,现在我想知道如何在c ++中执行此操作,换句话说,从函数生成的列表仍会在c ++中引用。
For example, I have a function: 例如,我有一个函数:
List foo(...){
.....
return List::create(Named("example1") = example1, Named("example2") = example2)
}
Now I have another function in C++ and example1
is a variable in the function, so how to reach example1
in C++. 现在我在C ++中有另一个函数,而
example1
是该函数中的变量,因此如何在C ++中达到example1
。
Thanks in advance. 提前致谢。 I am not familiar with C++.
我对C ++不熟悉。
我意识到返回值现在是一个列表,可以通过Rcpp::as<arma::mat>(...)
进行转换,'...'可以由列表名称和您想要的元素填充范围内,R中的总内容相同。感谢@DirkEddelbuettel的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.