Re-assigning vector in R

Hello,

I am joining a picture of what my data set looks like:

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.

Anyone could help ?

Thanks

I think what you need to do is join the perturbed data to the source data. If your data are in a data frame called DF, the code would look like this.

library(dplyr)
SourceData <- filter(DF, node_type = "source")
PerturbedData <- filter(DF, node_type = "perturbed")
JoinedData <- inner_join(SourceData, PerturbedData, by = c("node", "rep", "day"), suffix = c(".Src", ".Prtb"))

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.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.