You are in the 2nd circle of hell, namely failing to pre-allocate data structures.
Growing objects in this fashion is a Very Very Bad Thing in R. Either pre-allocate and insert:
df <- data.frame(x = rep(NA,20000),y = rep(NA,20000))
or restructure your code to avoid this sort of incremental addition of rows. As discussed at the link I cite, the reason for the slowness is that each time you add a row, R needs to find a new contiguous block of memory to fit the data frame in. Lots 'o copying.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…