Hello,
What you provided is not a reprex as Gini is not defined
df1 <- data.frame(name = c("a", "a", "b", "b", "c", "d"), value = c(5, 6, 15, 20, 35, 150),
year = c("2000","2000","2000","2001","2000","2000" ))
df2 <- data.frame(name = c("a", "b", "b", "b", "c", "d"), value = c(51, 26, 111, 24, 35, 150),
year = c("2000","2000","2000","2001","2000","2000" ))
#dfs <- ls()[sapply(mget(ls(), .GlobalEnv), is.data.frame)]
dfs <- list(df1,
df2)
for (j in 1:length(dfs)){
print(dfs[[j]]$value)
}
#> [1] 5 6 15 20 35 150
#> [1] 51 26 111 24 35 150
Created on 2020-11-09 by the reprex package (v0.3.0)
You'll see below I altered the code just to show you the format works now. The issue is your dfs structure is not a list but a character vector. You will see that it runs when you have a true list object passed into it.