0

Generalizing what my data sets look like I would like to combine them into a new data set C. What would be example code to do this? ( Say the data is on car crashes in Australia)

[Set A]

ID ----------------- Area Speed 

d1  --------------------50               

d2 --------------------70  

Notice that there are more observations in Set B since there is often more than 1 person involved in a crash:

Sex of person/s involved in that crash

License type of person/s involved in that crash

ID would be the date of which the crash occured

[Set B]

ID ----------------- Sex ----------------- License type

d1  - ------------------F ------------------------Full               

d1 --------------------M ------------------------Full

d2 --------------------M ------------------------P1

What I want to do is then combine both Set A and B such that it looks like this ( I don't really care about the ID in the end):

[Set C]

ID ----------------- Sex ----------------- License type  ----------------- Area Speed 

d1  - ------------------F ------------------------Full   --------------------------------50               

d1 --------------------M ------------------------Full    -------------------------------50

d2 --------------------M ------------------------P1     --------------------------------70
Agaz Wani
  • 5,514
  • 8
  • 42
  • 62
  • You have taken good effort to provide data in above format. I think it would have been easier for everyone if you could have created data frames and share as part of your question. – MKR Apr 21 '18 at 05:53
  • You can try `dplyr::left_join(Set_B, Set_A, by="ID")` – MKR Apr 21 '18 at 05:56
  • Thanks @MKR I will look into that –  Apr 21 '18 at 06:12

0 Answers0