22 #ifndef Rcpp__sugar__na_omit_h
23 #define Rcpp__sugar__na_omit_h
28 template <
int RTYPE,
bool NA,
typename T>
30 R_xlen_t n = x.size() ;
31 R_xlen_t n_out = n -
sum(
is_na(x) ) ;
33 if( n_out == n )
return x ;
36 for( R_xlen_t i=0, j=0; i<n; i++){
43 template <
int RTYPE,
bool NA,
typename T>
45 R_xlen_t n = x.size() ;
46 R_xlen_t n_out = n -
sum(
is_na(x) ) ;
48 if( n_out == n )
return x;
52 bool has_name = x.attr(
"names") != R_NilValue ;
57 for( R_xlen_t i=0, j=0; i<n; i++){
59 onames[j] = names[i] ;
62 out.
attr(
"names") = onames ;
64 for( R_xlen_t i=0, j=0; i<n; i++){
74 template <
int RTYPE,
bool NA,
typename T>
76 return sugar::na_omit_impl<RTYPE,NA,T>(
AttributeProxy attr(const std::string &name)
Vector< RTYPE > na_omit_impl(const T &x, Rcpp::traits::false_type)
sugar::IsNa< RTYPE, NA, T > is_na(const Rcpp::VectorBase< RTYPE, NA, T > &t)
sugar::Sum< INTSXP, NA, T > sum(const VectorBase< INTSXP, NA, T > &t)
no_init_vector no_init(R_xlen_t size)
Vector< RTYPE > na_omit(const VectorBase< RTYPE, NA, T > &t)