We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For a single element list, imodify() is dropping the list name. Here is a 2 element list, which returns what I would expect.
imodify()
library(purrr) # version 0.3.4 library(dplyr) mtcars1 <- mtcars[1, 1:2] mtcars2 <- mtcars[2, 1:2] # multi element list x <- lst(mtcars1, mtcars2) # okay imodify(x, ~ mutate(.x, mpg = log(mpg))) #> $mtcars1 #> mpg cyl #> Mazda RX4 3.044522 6 #> #> $mtcars2 #> mpg cyl #> Mazda RX4 Wag 3.044522 6
I would expect the single element list to provide the name as well. But it is unnamed ([[1]]). You do get the list name with modify().
[[1]]
modify()
# single element list y <- x[1] # unexpected imodify(y, ~ mutate(.x, mpg = log(mpg))) #> [[1]] #> mpg cyl #> Mazda RX4 3.044522 6 # okay modify(y, ~ mutate(.x, mpg = log(mpg))) #> $mtcars1 #> mpg cyl #> Mazda RX4 3.044522 6
Created on 2021-06-04 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered:
Somewhat more minimal reprex:
library(purrr) x <- list(x = 10, y = 20) str(imodify(x, \(x, y) y)) #> List of 2 #> $ x: chr "x" #> $ y: chr "y" str(imodify(x[1], \(x, y) x * 2)) #> List of 1 #> $ : num 20
Created on 2022-08-23 by the reprex package (v2.0.1)
Sorry, something went wrong.
Also part of #878
No branches or pull requests
For a single element list,
imodify()
is dropping the list name. Here is a 2 element list, which returns what I would expect.I would expect the single element list to provide the name as well. But it is unnamed (
[[1]]
). You do get the list name withmodify()
.Created on 2021-06-04 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered: