Guest User

Untitled

a guest
Jun 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. x1 <- c('NA','NA', 'NA)
  2. x2 <- c(NA,NA,NA)
  3.  
  4. #include <Rcpp.h>
  5. using namespace Rcpp;
  6.  
  7. // [[Rcpp::export]]
  8. NumericVector timesTwo(NumericVector x) {
  9.  
  10. if (all(is_na(x)) || (x == NA_STRING))
  11. {
  12. Rcout << "NA";
  13. }
  14.  
  15. return x * 2;
  16. }
  17.  
  18.  
  19. /*** R
  20. x1 <- c('NA','NA','NA')
  21. x2 <- c(NA,NA,NA)
  22. timesTwo(x1)
  23. timesTwo(x2)
  24. */
Add Comment
Please, Sign In to add comment