I'm trying to use ifelse()
command of Rcpp sugar with arma::vec
. The code fails with error
'ifelse' was not declared in this scope
I could not find a solution. A simple example code (resulted with error) is below.
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
arma::vec f(arma::vec x, arma::vec y) {
arma::vec res1 = Rcpp::ifelse(x < y, x, y);
arma::vec res = trans(res1)*y;
return res;
}
/*** R
f(c(1,2,3),c(3,2,1))
*/
Rcpp::ifelse
, but this won't work witharma::vec
. – FlagpoleRcpp::NumericVector
) does not necessarily work on another (iearma::vec
). – Druseas.double
oras.data.frame
inR
. For exampleas.Numeric.Vector
here. But it seems there is not. – Sleigh