Nested forloop - adding rows to dataframe

See the FAQ: How to do a minimal reproducible example reprex for beginners, please, because questions are hard helpfully to address in the abstract. Right now, all I can suggest is that R is best addressed as a functional language, rather than an imperative one. Taken as pcode, the example is perfectly fine and would translate easily into Python, for example, but not so well into R, which requires tricks to deal with both i and j indices at the same time.