Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x1 <- c('NA','NA', 'NA)
- x2 <- c(NA,NA,NA)
- #include <Rcpp.h>
- using namespace Rcpp;
- // [[Rcpp::export]]
- NumericVector timesTwo(NumericVector x) {
- if (all(is_na(x)) || (x == NA_STRING))
- {
- Rcout << "NA";
- }
- return x * 2;
- }
- /*** R
- x1 <- c('NA','NA','NA')
- x2 <- c(NA,NA,NA)
- timesTwo(x1)
- timesTwo(x2)
- */
Add Comment
Please, Sign In to add comment