We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2a33dcc commit 2cd6f61Copy full SHA for 2cd6f61
inst/include/Rcpp/sugar/functions/na_omit.h
@@ -30,7 +30,9 @@ namespace sugar{
30
R_xlen_t n = x.size() ;
31
R_xlen_t n_out = n - sum( is_na(x) ) ;
32
33
- Vector<RTYPE> out(n_out) ;
+ if( n_out == n ) return x ;
34
+
35
+ Vector<RTYPE> out = no_init(n_out) ;
36
for( R_xlen_t i=0, j=0; i<n; i++){
37
if( Vector<RTYPE>::is_na( x[i] ) ) continue ;
38
out[j++] = x[i];
@@ -43,7 +45,10 @@ namespace sugar{
43
45
44
46
47
48
+ if( n_out == n ) return x;
49
50
51
52
bool has_name = x.attr("names") != R_NilValue ;
53
if( has_name ){
54
CharacterVector names = x.attr("names") ;
0 commit comments