Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the use of {.col} and {.fn} in across() #100

Merged
merged 3 commits into from
Jul 31, 2022

Conversation

etiennebacher
Copy link
Contributor

Related to #52.

Before:

library(poorman)
#> 
#>   I'd seen my father. He was a poor man, and I watched him do astonishing things.
#>     - Sidney Poitier
#> 
#> Attaching package: 'poorman'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
min_max <- list(
  min = ~min(.x, na.rm = TRUE), 
  max = ~max(.x, na.rm = TRUE)
)

dplyr::starwars %>% 
  summarise(across(where(is.numeric), min_max, .names = "{.fn}.{.col}"))
#>   X..fn....col. NA. NA..1 NA..2 NA..3 NA..4
#> 1            66 264    15  1358     8   896

Created on 2022-07-28 by the reprex package (v2.0.1)

After:

library(poorman)
#> 
#>   I'd seen my father. He was a poor man, and I watched him do astonishing things.
#>     - Sidney Poitier
#> 
#> Attaching package: 'poorman'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
min_max <- list(
  min = ~min(.x, na.rm = TRUE), 
  max = ~max(.x, na.rm = TRUE)
)

dplyr::starwars %>% 
  summarise(across(where(is.numeric), min_max, .names = "{.fn}.{.col}"))
#>   min.height max.height min.mass max.mass min.birth_year max.birth_year
#> 1         66        264       15     1358              8            896

Created on 2022-07-28 by the reprex package (v2.0.1)

Note that the function stolen from gluestick is under the MIT license, which says that "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.". Not sure what it means but maybe you know.

@nathaneastwood nathaneastwood merged commit f7962ef into nathaneastwood:master Jul 31, 2022
nathaneastwood added a commit that referenced this pull request Jul 31, 2022
* enable the use of {.col} and {.fn} in across()

Co-authored-by: Nathan Eastwood <[email protected]>
@etiennebacher etiennebacher deleted the feat_across_glue branch August 3, 2022 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants