I'm only a beginner with R so please don't answer too complicated.
So, basically, I have "source" node and "perturbed" nodes. Basically I'm interested in the effect of the density of the source node on the average length in my perturbed node. So I want to be able to re-assign the density, so that, for my source node, my last column gives me the density of the corresponding perturbed node (same replicate, same day), and not the density of the source.
That will give you a new data frame with both the source and perturbed data matched by node, rep and day.
I could not test the code since I do not have your data. I hope I did not make any mistakes.