user41096 user41096 - 2 months ago 15
R Question

merging between two tables in R

I have a first table "results" of size 5313 rows and a second table "Lpp_sans_rss" size 3889 rows. I would like to create a merge between the tables by adding only the second column "lpp_libelle" from the second table in the last column of the first table. My problem is : when i make merge between these two tables, i get "124556" rows. I want to keep the same size of the first table by adding the "libell" of each "lpp_code"

Example of table 1 :

code_acte;lpp_code;count;expected_count;p-value;ROR;drug_margin;event_margin;FDR
NGQK001 ;985675;3;0.00894810101411811;9.99200722162641e-16;689.196078431372;105;6;2.11945533050936e-16
DASA006 ;985536;3;0.0159787518109252;9.99200722162641e-16;288.012295081967;9;125;2.11778383576921e-16


example of table 2 :

lpp_code;lpp_libelle
953082;IMP RES SEPRAFILM 13X15CM 430103 (A56D)
3115092;ENDOPROT CORONAIRE, STENT LIB. ZOTAROLIMUS, MEDTRONIC,RESOLUTE INTEGRITY,3MM.


Thank you.

Answer

The left outer join (or simply left join) described in the following question should solve your problem.

merge(x = results, y = Lpp_sans_rss, by = "ENTERHEREYOURCRITERIA", all.x = TRUE)

How to join (merge) data frames (inner, outer, left, right)?

Comments