1
我有數據作爲樣品如下:分配對面標籤
customerNames.1=c('A','B','A','C','E','F')
customerNames.2=c('B','A','C','A','F','E')
Relation=c('Father','NA','Spouse','NA','Mother','NA')
Datasample=data.table(customerNames.1,customerNames.2,Relation)
# data looks like
customerNames.1 customerNames.2 Relation
1: A B Father
2: B A NA
3: A C Spouse
4: C A NA
5: E F Mother
6: F E NA
每一行顯示customer.1的關係customer.2,而這裏A到B的關係是存在的主要來源,我也要錄製B到A與他們的關係(這可以從第一關係,如父親導出 - 子女,配偶 - 配偶,母 - 子)
我如何獲得像下面的東西:
customerNames.1 customerNames.2 Relation
1: A B Father
2: B A Child
3: A C Spouse
4: C A Spouse
5: E F Mother
6: F E Child
是這個作品! – Pb89