convertor of R code to RcppArmadillo code