Good job coming up with a reproducible example on your very first question!
I think the nested data.frame set-up works well with the
pwalk() variants of the map family. These functions are handy for rowwise work, where you want to go through each row of a data.frame and do something with the values in the columns. Here you want to go through each row of the nested data frame and save the
data given the
I would use
pwalk(), since you don't want anything returned within R but instead are saving something and
walk() variants are ...for functions called primarily for their side-effects; it returns
The code would then look like:
pwalk(~write_csv(x = .y, path = paste0(.x, ".csv") ) )
data column is the second column (the
.y element), so is passed to the first argument in
write_csv(). The first column (the
.x element) contains the country names, which I paste together with
.csv to make the names of the datasets that are saved.