add R implementation with Rcpp package