>> What are the advantages/disadvantages of doing that over (say) x_[i] >> == NA_REAL ? >> > it works ;-) > > x == NA_REAL does not work.
Ok, that makes sense. I thought it worked because the function below did what I expected. But now I guess that must be because < and > must return false when comparing a double to a missing value. fast_range <- cxxfunction(signature(x = "numeric"), plugin = "Rcpp", ' double min = INFINITY; double max = -INFINITY; Rcpp::NumericVector x_(x); int n = x_.size(); for(int i = 0; i < n; i++) { if (x_[i] == NA_REAL) continue; if (x_[i] < min) min = x_[i]; if (x_[i] > max) max = x_[i]; } return(NumericVector::create(min, max)); ') Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel