Reputation: 228
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))
}
Upvotes: 0
Views: 255
Reputation: 2216
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
Upvotes: 1