Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MilesMcBain/wisegroup
Now I am become death, destroyer of groups....
https://github.com/MilesMcBain/wisegroup
Last synced: 9 days ago
JSON representation
Now I am become death, destroyer of groups....
- Host: GitHub
- URL: https://github.com/MilesMcBain/wisegroup
- Owner: MilesMcBain
- License: other
- Created: 2019-11-26T22:07:36.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-03T11:17:42.000Z (about 5 years ago)
- Last Synced: 2024-11-30T20:53:22.993Z (12 days ago)
- Language: R
- Size: 67.4 KB
- Stars: 40
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - MilesMcBain/wisegroup - Now I am become death, destroyer of groups.... (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# wisegroup
[![Travis build status](https://travis-ci.org/milesmcbain/wisegroup.svg?branch=master)](https://travis-ci.org/milesmcbain/wisegroup)
> Now I am become death, destroyer of groups....
Never be burned by forgetting to `ungroup()` again.
This packages contains alternative versions of common group-aware `tidyverse` functions that either:
* automatically ungroup the returned data OR
* allow the developer to make explicit that groups are being carried forward, signalling the potential for group related errors with a '...' variant of the orignal function, e.g. `mutate...`, `summarise...` etc.## Installation
```{r, eval = FALSE}
remotes::install_github("milesmcbain/wisegroup")
```## Usage
`wisegroup` is designed to mask `tidyverse` functions in your global
environment. It is recommended that you use this package in conjunction with
`conflicted`. This means that the order of the `library` calls will not matter,
and that the masking is made explicit like so:```{r}
library(conflicted)
library(wisegroup)
library(tidyverse)
library(nycflights13)conflict_prefer("summarise", "wisegroup")
conflict_prefer("mutate", "wisegroup")```
Just be lazy. `conflicted` will let you know when you need to disambiguate.
So now you have automatically dropped groups after summarising over
multiple grouping columns:```{r}
grouped_no_more <-
flights %>%
group_by(year, month, day) %>%
summarise(max_delay = max(dep_delay, na.rm = TRUE))grouped_no_more
```
You indicate the grouping is sticking around with the `...` suffix
```{r}
still_grouped <-
flights %>%
group_by(year, month, day) %>%
summarise...(max_delay = max(dep_delay, na.rm = TRUE))still_grouped
```
and with mutate:
```{r}
summarised_over_mutates_groups <-
flights %>%
group_by(year, month, day) %>%
mutate...(day_dep_variance = var(dep_delay, na.rm = TRUE)) %>%
summarise(max_var = max(day_dep_variance))summarised_over_mutates_groups
```
## Fun Fact
This package generates its own source and documentation, so that adding new
wrappers is low effort.To generate new wrappers, an entry is added to
"./group_aware_functions.R" and "./make.R" is run.## Contributing
If there's a function you think should be included make a PR for "./group_aware_functions.R"!