[Rcpp-devel] Using Armadillo objects as arguments in calls to R

Davor Cubranic cubranic at stat.ubc.ca
Tue May 11 21:35:01 CEST 2010


Can anyone tell me about issues I have to look out for when dealing with Rcpp Functions and passing Armadillo objects as arguments? I'm getting "not compatible with INTSXP" and segfault errors when calling the following Rcpp equivalent of R's 'predict(loess(y~x, weights=w, span=span))'. The errors usually only manifest only after several dozen calls.

Davor


const vec predict(const vec& x, const vec& y,
			const vec& weights, const double span) {
  Function formula_fn("formula");
  Function loess_fn("loess");
  Function predict_fn("predict");

  List data = List::create(_["x"] = wrap(x),
			   _["y"] = wrap(y));
  NumericVector weights_r = wrap(weights);
  const NumericVector out_r = predict_fn(loess_fn(formula_fn("y~x"),
						  data,
						  weights_r,
						  Named("span") = span));
  const vec out = vec(out_r.begin(), out_r.size());
  return out;
}


More information about the Rcpp-devel mailing list