list_of_vectors <- list(one = c(1, 2, 3), two = c(4, 5, 6))
purrr::map(list_of_vectors, ~purrr::map(., ~.+1))
#> $one
#> $one[[1]]
#> [1] 2
#>
#> $one[[2]]
#> [1] 3
#>
#> $one[[3]]
#> [1] 4
#>
#>
#> $two
#> $two[[1]]
#> [1] 5
#>
#> $two[[2]]
#> [1] 6
#>
#> $two[[3]]
#> [1] 7
purrr::modify_depth(list_of_vectors, 2, ~.+1)
#> Error: List not deep enough
Example:
I think
at_depthused to not give this error in this same context. I feel thatmodify_depthis working exactly as intended, but it is still confusing that it should be so easy to construct a case that explicitly contradicts the documentation for themodify_depthdocumentation. Maybemapshouldn't work on vectors as well?