0

I am trying to convert my list that has 48 components to a consolidated data frame using the for loop:

df1 = as.data.frame(list[1])
df2 = as.data.frame(list[2])
df3 = as.data.frame(list[3])
.
.
.
df48 = as.data.frame(list[48])
library(dplyr)

bda <- bda %>% 
  select(UNIQUE_CODE) 

for (i in 1:length(mi_lista)) {
  bd <- as.data.frame(mi_lista[[i]])
  df <- left_join(bda, bd)
}

Thanks so much

shafee
  • 15,566
  • 3
  • 19
  • 47
LorenaR
  • 41
  • 1
  • 1
    Why is it necessary to use a loop? Can't you use any of [these solutions](https://stackoverflow.com/questions/4227223/convert-a-list-to-a-data-frame)? – Ignatius Reilly Oct 20 '22 at 02:33
  • Cant really tell what you are trying to achieve. Probably you need to use `list2DF(your_list)` – Onyambu Oct 20 '22 at 02:44
  • Thanks for your contributions. I changed bda to df and the problem was solved – LorenaR Oct 21 '22 at 14:57

0 Answers0