Skip to content

Commit

Permalink
test for #1185. closes #1185
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed May 3, 2018
1 parent bb3fa9d commit 5870af0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Result* get_handler(SEXP call, const ILazySubsets& subsets, const Environment& e

if (TYPEOF(call) == LANGSXP) {
int depth = Rf_length(call);

HybridHandlerMap& handlers = get_handlers();

bool in_dplyr_namespace = false;
Expand Down
6 changes: 3 additions & 3 deletions src/hybrid_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ using namespace dplyr;
class GroupHybrid : public Result {
public:
SEXP process(const RowwiseDataFrame&) {
Rprintf( "GroupHybrid::RowwiseDataFrame()\n" ) ;
Rprintf("GroupHybrid::RowwiseDataFrame()\n") ;
return R_NilValue ;
}

SEXP process(const GroupedDataFrame&) {
Rprintf( "GroupHybrid::GroupedDataFrame()\n" ) ;
Rprintf("GroupHybrid::GroupedDataFrame()\n") ;
return R_NilValue ;
}

SEXP process(const FullDataFrame&) {
Rprintf( "GroupHybrid::FullDataFrame()\n" ) ;
Rprintf("GroupHybrid::FullDataFrame()\n") ;
return R_NilValue ;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-group-indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ test_that("group indices are updated correctly for joined grouped data frames (#
res <- inner_join(d1, d2, by = "x")
expect_equal(group_indices(res), res$x)
})

test_that("group_indices() can be used inside mutate (#1185)", {
df <- data_frame(v1 = c(3, 3, 2, 2, 3, 1), v2 = 1:6) %>% group_by(v1)
expect_identical(
pull(mutate(df, g = group_indices())),
group_indices(df)
)

df <- data_frame(v1 = c(3, 3, 2, 2, 3, 1), v2 = 1:6)
expect_identical(
pull(mutate(df, g = group_indices())),
rep(0L, 6)
)
})

0 comments on commit 5870af0

Please sign in to comment.