considering following list
df <- list(list(a = 1, b = NA_real_, c = NA_real_, d = NA_real_, e = NA_real_),
list(a = 1, b = NA_real_, c = NA_real_, d = NA_real_, e = NA_real_),
list(a = 1, b = NA_real_, c = NA_real_, d = NA_real_, e = NA_real_),
list(a = 1, b = NA_real_, c = NA_real_, d = NA_real_, e = NA_real_),
list(a = 1, b = NA_real_, c = NA_real_, d = NA_real_, e = NA_real_))
I want to change the value in position "a" according the outer list index like this:
df[[1]]$a <- 1
df[[2]]$a <- 2
df[[3]]$a <- 3
But I want to use purrr functions like
library(tidyverse)
df %>%
modify_depth(1, ~modify_at(., "a", ~. + 1))
I'm pretty sure that we can use modify2 for such thing. But don't get it.