Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hadley/dplyr
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jan 9, 2015
2 parents 1c0e907 + 4801e3b commit 1f57c48
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
missing values (#774). `row_number()` doesn't segfault when giving an external
variable with the wrong number of variables (#781)

* `group_indices` handles the edge case when there are no variables (#867)

# dplyr 0.3.0.1

* Fixed problem with test script on Windows.
Expand Down
4 changes: 2 additions & 2 deletions R/funs.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Create a list of functions calls.
#'
#' \code{funs} provides a flexible to generate a named list of functions for
#' input to other functions like \code{colwise}.
#' \code{funs} provides a flexible way to generate a named list of functions for
#' input to other functions like \code{summarise_each}.
#'
#' @param dots,... A list of functions specified by:
#'
Expand Down
2 changes: 2 additions & 0 deletions src/group_indices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ IntegerVector grouped_indices_grouped_df_impl( GroupedDataFrame gdf ){
// [[Rcpp::export]]
IntegerVector grouped_indices_impl( DataFrame data, ListOf<Symbol> symbols ){
int nsymbols = symbols.size() ;
if( nsymbols == 0 )
return rep(1, data.nrows()) ;
CharacterVector vars(nsymbols) ;
for( int i=0; i<nsymbols; i++){
vars[i] = PRINTNAME(symbols[i]) ;
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-group-indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@ test_that("group_indices from ungrouped or grouped gives same result", {
expect_equal(res1, res2)
})

test_that("group_indices handles the case where no variable is given (#867)", {
res <- group_indices(mtcars)
expect_true( all(res==1L) )
})

test_that("group_indices handles grouped data and no arguments", {
res1 <- mtcars %>% group_by(cyl) %>% group_indices()
res2 <- mtcars %>% group_indices(cyl)
expect_equal(res1, res2)
})

0 comments on commit 1f57c48

Please sign in to comment.