0

I have a double repeated measures dataset (i.e., a participant is measured 3 times per session, and repeats session 2 times). Some of my data is preliminary demographic data that is only measured once (e.g., surveys) while the others are all repeated. A toy dataset is shown below:

Session 1: Session 1

Session 2: enter image description here

Survey Q1-Q5 are all the same, as they were preliminary measurements. The measurements are, however, different.

I've been able to join these 2 datasets by:

join <- left_join(Session1,Session2, by = "ID")

However, I want to exclude any of the preliminary surveys from session 2 so that only that info from session 1 is brought over to the new dataframe. The above line of code does not achieve that.

How might I be able to go about doing this?

Thanks!

r_user
  • 317
  • 3
  • 11
  • 1
    If I understand correctly, can you just exclude these columns from `Session2` before merging? So: `join <- left_join(Session1, select(Session2, -Survey_Q1, -Survey_Q2, -Survey_Q3, -Survey_Q4, -Survey_Q5), by = "ID)` – Brigadeiro Aug 30 '20 at 15:38
  • That makes sense. I was hoping for some magical code solution. But IG I got too far into it without thinking! Thanks! – r_user Aug 30 '20 at 15:57
  • 1
    If there is something more complex that you need to achieve programatically I would be happy to help out, but this seems like the simplest way to do it for this use case! – Brigadeiro Aug 30 '20 at 23:13

1 Answers1

0

Just exclude the columns that you don't want. join <- left_join(Session1,Session2[,-c(2:6)], by = "ID") or join <- left_join(Session1,Session2[,-c("Survey_Q1","Survey_Q2","Survey_Q3","Survey_Q4","Survey_Q5")], by = "ID")

Tanner33
  • 120
  • 2
  • 15