Skip to content

collapse version 2.0.14

Latest
Compare
Choose a tag to compare
@SebKrantz SebKrantz released this 20 May 15:14
· 5 commits to master since this release
  • Updated 'collapse and sf' vignette to reflect the recent support for units objects, and added a few more examples.

  • Fixed a bug in join() where a full join silently became a left join if there are no matches between the tables (#574). Thanks @D3SL for reporting.

  • Added function group_by_vars(): A standard evaluation version of fgroup_by() that is slimmer and safer for programming, e.g. data |> group_by_vars(ind1) |> collapg(custom = list(fmean = ind2, fsum = ind3)). Or, using magrittr:

library(magrittr)
set_collapse(mask = "manip") # for fgroup_vars -> group_vars

data %>% 
  group_by_vars(ind1) %>% {
  add_vars(
    group_vars(., "unique"),
    get_vars(., ind2) %>% fmean(keep.g = FALSE) %>% add_stub("mean_"),
    get_vars(., ind3) %>% fsum(keep.g = FALSE) %>% add_stub("sum_")
  ) 
}
  • Added function as_integer_factor() to turn factors/factor columns into integer vectors. as_numeric_factor() already exists, but is memory inefficient for most factors where levels can be integers.

  • join() now internally checks if the rows of the joined datasets match exactly. This check, using identical(m, seq_row(y)), is inexpensive, but, if TRUE, saves a full subset and deep copy of y. Thus join() now inherits the intelligence already present in functions like fsubset(), roworder() and funique() - a key for efficient data manipulation is simply doing less.

  • In join(), if attr = TRUE, the count option to fmatch() is always invoked, so that the attribute attached always has the same form, regardless of verbose or validate settings.

  • roworder[v]() has optional setting verbose = 2L to indicate if x is already sorted, making the call to roworder[v]() redundant.