alist contains a list of data frames. The first map() loops on the list and returns a list, the inside map_dbl() loops on the columns of the data frame and returns a double for each vector.
If you typed what you suggest, map(alist, ~mean(.x)) this means the map() loops on the list, and gives a whole dataframe to mean() in the variable .x. So it is equivalent to such a loop:
for(i in 1:length(alist)){
.x <- alist[[i]]
mean(.x)
}
In the example, alist %>% map(. %>% map_dbl(mean)) is equivalent to map(alist, ~ map_dbl(.x, mean)) and would be equivalent to such a structure:
for(i in 1:length(alist)){
my_df <- alist[[i]]
for(j in 1:length(names(my_df))){
my_col <- my_df[[j]]
mean(my_col)
}
}
PS: Just note that the for loops here are for illustration. In real life i and j have no reason to be numerical and could contain the whole dataframe and the name of the column, for example. Also, you'd have to package the means back into a dataframe to return them, which map_dbl() is taking care of here.