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

Ensure that recycling uses tidyverse rules #878

Closed
hadley opened this issue Aug 24, 2022 · 2 comments · Fixed by #917
Closed

Ensure that recycling uses tidyverse rules #878

hadley opened this issue Aug 24, 2022 · 2 comments · Fixed by #917
Labels
bug an unexpected problem or unintended behavior map 🗺️

Comments

@hadley
Copy link
Member

hadley commented Aug 24, 2022

i.e. only recycle vectors of length 1.

Problems include at least:

purrr:::recycle_args(list(1, integer(0)))
#> Error in purrr:::recycle_args(list(1, integer(0))): all(lengths == 1L | lengths == n) is not TRUE
purrr::map2(integer(0), 1:2, list)
#> list()
purrr::pmap(list(integer(0), 1:2), list)
#> list()

Created on 2022-08-24 by the reprex package (v2.0.1)

@hadley
Copy link
Member Author

hadley commented Aug 27, 2022

Make sure to also test that data frames are correctly recycled:

purrr::modify2(data.frame(x = 1), 1:2, ~ .)

@hadley
Copy link
Member Author

hadley commented Aug 27, 2022

And

library(purrr)
x <- list(x = 10, y = 20)
names(imodify(x[1:2], \(x, y) x * 2))
#> [1] "x" "y"
names(imodify(x[1], \(x, y) x * 2))
#> NULL

Created on 2022-08-27 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior map 🗺️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant