I'm attempting to remove a subject from the data set and then subsequently merge them in with the others so that their values at each time point can be compared to everyone else.
This is what the data looks like:
subject <- rep(1:5, each = 20)
seconds <- rep(1:20, times = 20)
variable <- rnorm(n = subject, mean = 20, sd = 10)
d <- data.frame(subject, seconds, variable)
Then, I am removing subject four from the data and trying to merge them back to compare them to each of the other subjects:
four <- subset(d, subject == 4)
d2 <- subset(d, subject != 4)
I've tried this but the problem is that it repeats each of the seconds 4 times for each merge:
merge(d2, four, by = "seconds")
Is there a way to get an exact merge of each individual relative to subject 4?