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

Fix .id arg missing in imap_dfr #454

Merged
merged 5 commits into from Feb 5, 2018

Conversation

Projects
None yet
2 participants
@cderv
Contributor

cderv commented Feb 5, 2018

This is a small PR that fixes #429

  • .id argument in imap_dfr is now took into account (see reprex below)

  • unused .id argument in imap_dfc is now suppressed

  • Verifying if it was all, I found that in flatten_df* verbs there was no check if dplyr is installed or not as in map_df*, map2_df*, and pmap_df*. As it is small changes, I have included in this PR rather than opening a new one

Checking the fix

library(purrr)
as_tibble_custom <- function(value, name = NULL) {
  tab <- tibble::as_tibble(value)
  if (! is.null(name)) {
    tab$col_id = paste0("col_", name)
  }
  tab
}
# 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.00 col_a 
#> 2  2.00 col_b 
#> 3  3.00 col_c
list(a = 1, b = 2, c = 3) %>%
  imap_dfr(as_tibble_custom, .id = "name")
#> # A tibble: 3 x 3
#>   name  value col_id
#>   <chr> <dbl> <chr> 
#> 1 a      1.00 col_a 
#> 2 b      2.00 col_b 
#> 3 c      3.00 col_c

cderv added some commits Feb 5, 2018

NEWS.md Outdated
@@ -1,6 +1,10 @@
# purrr 0.2.4.9000
* `flatten_dfr` and `flatten_dfc` now aborts if `dplyr` is not installed. (#454)

This comment has been minimized.

@hadley

hadley Feb 5, 2018

Member

House style is to not put package names in back ticks, and to put () after function names. Can you please change?

This comment has been minimized.

@cderv

cderv Feb 5, 2018

Contributor

Oh sorry for that. I will definitely remember that for next time.
And revise the tidyverse style guide.
Correction is done.

@hadley hadley merged commit f7010b7 into tidyverse:master Feb 5, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@cderv cderv deleted the cderv:fix-id-arg branch Feb 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment