Hi @Varvara! Welcome!
Each iteration of your loop is overwriting d
, instead of adding to it. So at the end of the loop, d
has the value of the last time it was created (the last loop iteration). If you mean to be updating df
, then you’d write:
df = rbind(df, df.smos.s1)
If you want your final combined object to be named d
, then you’d change the line at the beginning to
d = NULL
And the later line to:
d = rbind(d, df.smos.s1)
As a note, it’s possible to do this sort of task in R without using a for
loop (or, to be more precise, using functions whose underlying loops are written by somebody else, often in a more optimized way). The base R idiom here would be lapply()
plus do.call(rbind, ...)
. In the tidyverse
idiom, you’d use purrr::map_dfr().
Another note: we ask posters here to properly format their code. It makes the site easier to read, prevents confusion (unformatted code can mistakenly trigger other types of automatic formatting) and generally is considered the polite thing to do. You can read all the details of how to do it here: FAQ: How to make your code look nice? Markdown Formatting
Or try the easy way : select code (in blocks or in bits and pieces mixed into your sentences) and click the little </>
button at the top of the posting box.