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

Behavior of *_at() functions with unnamed input #673

Closed
echasnovski opened this issue May 25, 2019 · 1 comment
Closed

Behavior of *_at() functions with unnamed input #673

echasnovski opened this issue May 25, 2019 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@echasnovski
Copy link

After using *_at() functions, I feel like their behavior is a little inconsistent. In documentation it says "modify_at() only modifies elements given by names or positions." and "Only those elements corresponding to .at will be modified." I read this as: try finding elements specified in .at and modify them, while not touching anything else.

When .at is a string, it works exactly like that when at least one list element is named. However, it throws error when there are no names, in which case I'd expect it to not find any .at elements and modify nothing while returning the input.

A reprex:

library(purrr)

map_at(list(1, a = 2), .at = "a", ~. + 1)
#> [[1]]
#> [1] 1
#> 
#> $a
#> [1] 3
map_at(list(1, b = 2), .at = "a", ~. + 1)
#> [[1]]
#> [1] 1
#> 
#> $b
#> [1] 2

map_at(list(1, 2), .at = "a", ~. + 1)
#> Error: character indexing requires a named object
modify_at(list(1, 2), .at = "a", ~. + 1)
#> Error: character indexing requires a named object

Created on 2019-05-25 by the reprex package (v0.3.0)

@lionel- lionel- added the bug an unexpected problem or unintended behavior label Jan 20, 2020
@hadley
Copy link
Member

hadley commented Aug 24, 2022

I think we will deprecate/superseded the _at functions (#874) so we no longer to plan this to fix this.

@hadley hadley closed this as completed Aug 24, 2022
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
Projects
None yet
Development

No branches or pull requests

3 participants