0

I have a code that I want it to be repeated for three times, at each time I have outputs of data frame as df1, df2,... and inside this loop I have another loop that says bind this data frames by row, my problem is how to put index to " e<-bind_rows(listdf))" (I should have three "e" ) so at the end I could bind the three "e"s and have one dataframe including df1, df2,... for three repeats of index i.

In advance, I really appreciate your response.

for (i in 1:3){
(there are some codes in here which uses i as index and gives:)
df1=...
df2=...

listdf<-list()
for (j in 1:20){
z <- j
sdf <- paste("df", z, sep="")
ddf <- get(paste("df", z, sep=""))
listdf[[sdf]] <-ddf
}
e<-bind_rows(listdf)) 

}
Helia
  • 228
  • 1
  • 10
  • It's hard to tell exactly what you are doing here with the `...` and whatnot. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. It's better to avoid get/assign and just work with proper lists of data.frames. – MrFlick Feb 27 '19 at 21:29

1 Answers1

1

You can use the assign function to save each e with lets say a number beside it. It will be something like this:

assign(paste0("e",i),bind_rows(listdf))

You will end up with e1, e2 and e3

Alejandro Andrade
  • 2,196
  • 21
  • 40