Similar to this question, I would like to do the same but to a list of tibbles.
How can I do this?
Sample Data & code:
library(tidyverse)
tbl1 = tibble(x = c('a', 'b', 'c'), y = 1:3)
tbl2 = tibble(x = c('11', '12', '13'), y = 1:3)
tbl = list(tbl1, tbl2)
data_types = rep(c("character"),times = 3)
tbl[] = map2(tbl, str_c("as.", data_types), ~ get(.y)(.x))
Error:
Error: Mapped vectors must have consistent lengths:
* `.x` has length 2
* `.y` has length 3