I have a list that contains data grouped into world regions. Now I want to extract each region into a data frame and only select certain columns to do more analysis on. I found myself doing a lot of copying and pasting so I think I should write a function to do it for me. Here is my code that didn't work:
lapply(data_list, function(x){
for (x in 1:length(data_list)) {
assign(paste0("data_list", x), as.data.frame(data_list[[x]]))} # split the list into data frames
a = paste0('x', '1') <- subset(data_listx, select = c(1, 4, 5, 17:62))
View(a)
})
Any thoughts on how I should rewrite it?