I'd like to use some combination of purrr::map
and purrr::possibly
to achieve the below. Is this possible?
mixed_list <- list(mtcars, mtcars, letters)
for (i in seq_along(mixed_list)){
print(i)
if (class(mixed_list[[i]]) == "data.frame"){
mixed_list[[i]] <- as.matrix(mixed_list[[i]])
}
}
#> [1] 1
#> [1] 2
#> [1] 3