#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
arma::mat fed(arma::mat x){
arma::mat zz=x.shed_rows(0,2);
return(zz);
}
Run Code Online (Sandbox Code Playgroud)
只想从矩阵中删除一些行,得到如下错误.从'void'转换为非标量类型'arma :: Mat}''
两点:
shed_rows()方法不返回任何内容.相反,它改变了它所作用的矩阵,参见文档.以下作品:
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
arma::mat fed(arma::mat x){
x.shed_rows(0,2);
return(x);
}
/*** R
fed(matrix(1:16, 4 ,4))
*/
Run Code Online (Sandbox Code Playgroud)