Double merge two data frames in r -


मेरे पास दो डेटाफ्रेम हैं

  df1 = data.frame (साइट्स = सी ("ए "बी", "सी"), कुल = सी (12,635)) df2 = data.frame (साइट 1 = सी ("ए", "ए", "बी"), साइट 2.2 = C ("बी", "सी", "सी"), स्कोर = सी (60,70,80))   

मुझे डेटाफ्रेम तैयार करने के लिए उन्हें मर्ज करने की आवश्यकता है

  df3 = data.frame (साइट 1 = सी ("ए", "ए", "बी"), साइट 2.2 = सी ("बी", "सी", "सी") , स्कोर = सी (60,70,80), साइट .1। कुल = सी (12,12,6), साइट 2.क्षेत्र = सी (6,35,35))   

ऐसे डबल मर्ज करने के लिए सबसे सरल तरीके से कोई सलाह? धन्यवाद

बस मर्ज दो बार:

  एक्स एंड एलटी; - मर्ज (df2, df1, all.x = TRUE, द्वारा.x = "Site.2", by.y = "Sites", सॉर्ट = FALSE) मर्ज (x, df1, all.x = TRUE , By.x = "Site.1", by.y = "Sites", सॉर्ट = FALSE) साइट 1 साइट .2 कुल कुल कुल 1.x 1 एबी 60 6 12 2 एसी 70 35 12 3 बीसी 80 35 6    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -