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

Use tidyselect in map_at #608

Closed
ColinFay opened this issue Jan 2, 2019 · 3 comments

Comments

@ColinFay
Copy link
Contributor

commented Jan 2, 2019

It would be nice if map_at() could incorporate tidyselect functions:

library(purrr)
library(tidyselect)

map_at_two <- function(.x, .at, .f, ...){
  outvars <- vars_select(.vars = names(.x), .at)
  map_at(.x, outvars, .f, ...)
}

x <- list(a = "b", b = "c", aa = "bb")

map_at_two(x, contains("a"), toupper)
#> $a
#> [1] "B"
#> 
#> $b
#> [1] "c"
#> 
#> $aa
#> [1] "BB"

map_at_two(x, 1, toupper)
#> $a
#> [1] "B"
#> 
#> $b
#> [1] "c"
#> 
#> $aa
#> [1] "bb"

map_at_two(x, "a", toupper)
#> $a
#> [1] "B"
#> 
#> $b
#> [1] "c"
#> 
#> $aa
#> [1] "bb"

x <- list("b", "c", "bb")

map_at_two(x, contains("a"), toupper)
#> Error: No tidyselect variables were registered

<sup>Created on 2019-01-02 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)</sup>

{tidyselect} has purrr as a dependencies, so it might imply that {purrr} functions used in {tidyselect} have to be rewritten.

@lionel-

This comment has been minimized.

Copy link
Member

commented Jan 2, 2019

Sorry, purrr is unlikely to gain any NSE features. The right way to do it would be to take a vars() list by the way, as in mutate_at() etc.

@lionel- lionel- closed this Jan 2, 2019

@ColinFay

This comment has been minimized.

Copy link
Contributor Author

commented Jan 15, 2019

@lionel- just in case, this is the issue I've referred to tonight :)

@lionel- lionel- reopened this Jan 15, 2019

@ColinFay

This comment has been minimized.

Copy link
Contributor Author

commented Jan 19, 2019

Working on this one today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.