I am trying to insert many rows from one dataframe to another. I managed to do it once, but I have to do the same 3500 times.
I have the following two dataframes with the same headers:
dataframe a with 850561 rows and 121 columns
dataframe b with 854001 rows and 121 columns
And I used the following code to insert a row from b to a:
a <- rbind(a[1:244,],b[245],a[-(1:244),])
This works perfectly because it inserts a row from b in between rows 244 and 245 of a.
The problem is that I have to do the same every 243 rows, for example the next would be something like this:
a <- rbind(a[246:489,],b[489],a[-(246:489),])
I have tried with the following for loop, but it does not work:
i<-244
j<-1
for (val in a){
a<-rbind(a[j:i,],b[i+1],a[-(j:i),])
i<-i+243
j<j+245
}
I would much appreciate your help