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
Closed

Use tidyselect in map_at #608

ColinFay opened this issue Jan 2, 2019 · 3 comments

Comments

@ColinFay
Copy link
Contributor

@ColinFay ColinFay 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-
Copy link
Member

@lionel- lionel- 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.

Loading

@lionel- lionel- closed this Jan 2, 2019
@ColinFay
Copy link
Contributor Author

@ColinFay ColinFay commented Jan 15, 2019

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

Loading

@lionel- lionel- reopened this Jan 15, 2019
@ColinFay
Copy link
Contributor Author

@ColinFay ColinFay commented Jan 19, 2019

Working on this one today

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants