Last active
August 29, 2015 14:21
-
-
Save wckdouglas/22a2064ae51162ddd903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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