-
Notifications
You must be signed in to change notification settings - Fork 272
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
.id argument ignored in imap_dfr()/imap_dfc()? #429
Comments
It seems you are right. To illustrate, here is a dummy reprex with a custom to argument fonction to use with library(purrr)
library(tibble)
as_tibble_custom <- function(value, name = NULL) {
tab <- as_tibble(value)
if (! is.null(name)) {
tab$col_id = paste0("col_", name)
}
tab
}
# same as imap and it works
list(a = 1, b = 2, c = 3) %>%
map2_dfr(names(.), as_tibble_custom)
#> # A tibble: 3 x 2
#> value col_id
#> <dbl> <chr>
#> 1 1 col_a
#> 2 2 col_b
#> 3 3 col_c
list(a = 1, b = 2, c = 3) %>%
map2_dfr(names(.), as_tibble_custom, .id = "name")
#> # A tibble: 3 x 3
#> name value col_id
#> <chr> <dbl> <chr>
#> 1 a 1 col_a
#> 2 b 2 col_b
#> 3 c 3 col_c
# with imap it does not work
list(a = 1, b = 2, c = 3) %>%
imap_dfr(as_tibble_custom)
#> # A tibble: 3 x 2
#> value col_id
#> <dbl> <chr>
#> 1 1 col_a
#> 2 2 col_b
#> 3 3 col_c
list(a = 1, b = 2, c = 3) %>%
imap_dfr(as_tibble_custom, .id = "name")
#> # A tibble: 3 x 2
#> value col_id
#> <dbl> <chr>
#> 1 1 col_a
#> 2 2 col_b
#> 3 3 col_c In the source code, Moreover, |
Would either of you like to do a PR? This would be a great first PR if you haven't done one before. |
is it possible that this hasn't been pushed to CRAN, or that there has been a reversion? As expected, the above reprex from @cderv currently works off of github (the last) call is the interesting one):
but, apparently, not off of CRAN:
|
Looking at commits from tag v0.2.5 it seems CRAN version does not include any of the fixes since 0.2.4. It makes sense since it is indicated in the release pane:
However, version number in DESCRIPTION and in NEWS are not correct. Development version is less than current CRAN version. Not so clear. I am not aware of the release process so I let the purrr dev team say if there is something off or not. Also, I think it is a good practice to open a new issue rather than discussing in closed one. 🤔 |
purrr/R/imap.R
Line 50 in 62b135a
I don't seem to be able to make use of
.id
inimap_dfr()
. Looking at the source code, the.id
arg seems not to be handled at all. Is it the case or am I missing something?The text was updated successfully, but these errors were encountered: