Skip to content

Instantly share code, notes, and snippets.

@wckdouglas
Last active August 29, 2015 14:21
Show Gist options
  • Save wckdouglas/22a2064ae51162ddd903 to your computer and use it in GitHub Desktop.
Save wckdouglas/22a2064ae51162ddd903 to your computer and use it in GitHub Desktop.
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector removeNA(NumericVector a)
{
int vectorLength = a.size();
NumericVector result(vectorLength);
for (int i = 0; i < vectorLength ; i++)
{
if (NumericVector::is_na(a[i]))
{
result[i] = 0;
}
else
{
result[i] = a[i];
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment