DataFrame filter_grouped( const Data& gdf, const LazyDots& dots){ if( dots.single_env() ){ return filter_grouped_single_env<Data, Subsets>(gdf, dots) ; } else { return filter_grouped_multiple_env<Data, Subsets>(gdf, dots) ; } }
DataFrame filter_grouped( const GroupedDataFrame& gdf, const LazyDots& dots){ if( dots.single_env() ){ return filter_grouped_single_env(gdf, dots) ; } else { return filter_grouped_multiple_env(gdf, dots) ; } }
DataFrame filter_not_grouped( DataFrame df, const LazyDots& dots){ CharacterVector names = df.names() ; SymbolSet set ; for( int i=0; i<names.size(); i++){ set.insert( Rf_installChar( names[i] ) ) ; } if( dots.single_env() ){ Environment env = dots[0].env() ; // a, b, c -> a & b & c Shield<SEXP> call( and_calls( dots, set, env ) ) ; // replace the symbols that are in the data frame by vectors from the data frame // and evaluate the expression CallProxy proxy( (SEXP)call, df, env ) ; LogicalVector test = check_filter_logical_result(proxy.eval()) ; if( test.size() == 1){ if( test[0] == TRUE ){ return df ; } else { return empty_subset(df, df.names(), classes_not_grouped()) ; } } else { check_filter_result(test, df.nrows()); return subset(df, test, classes_not_grouped() ) ; } } else { int nargs = dots.size() ; Call call(dots[0].expr()); CallProxy first_proxy(call, df, dots[0].env() ) ; LogicalVector test = check_filter_logical_result(first_proxy.eval()) ; if( test.size() == 1 ) { if( !test[0] ){ return empty_subset(df, df.names(), classes_not_grouped() ) ; } } else { check_filter_result(test, df.nrows()); } for( int i=1; i<nargs; i++){ Rcpp::checkUserInterrupt() ; Call call( dots[i].expr() ) ; CallProxy proxy(call, df, dots[i].env() ) ; LogicalVector test2 = check_filter_logical_result(proxy.eval()) ; if( combine_and(test, test2) ){ return empty_subset(df, df.names(), classes_not_grouped() ) ; } } DataFrame res = subset( df, test, classes_not_grouped() ) ; return res ; } }