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)) 

}
1
  • 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 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. Commented Feb 27, 2019 at 21:29

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.