Skip to content

How debug map() calls that aren't working #3

@jennybc

Description

@jennybc

Question raised in connection to this example:

What if data frame includes variables that should not be passed to .f()?

df_oops <- tibble(
  n = 1:3,
  min = c(0, 10, 100),
  max = c(1, 100, 1000),
  oops = c("please", "ignore", "me")
)
df_oops
#> # A tibble: 3 x 4
#>       n   min   max oops  
#>   <int> <dbl> <dbl> <chr> 
#> 1     1    0.    1. please
#> 2     2   10.  100. ignore
#> 3     3  100. 1000. me

This will not work!

set.seed(123)
pmap(df_oops, runif)
#> Error in .f(n = .l[[c(1L, i)]], min = .l[[c(2L, i)]], max = .l[[c(3L, : unused argument (oops = .l[[c(4, i)]])

Use that to motivate some development and debugging strategies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions