2015-10-25 74 views
1

我有以下表:提取匹配的唯一值

> head (data6) 
                   verb_object SESSION_ID transactionID sequenceID eventID items 
    1:        34D89F927092290A5DA9B108F7020C19 SELECT 36652675   2058 36652675  1 OV1 
    2: 15873DB37BF80750C70B68A8778B9DC01D548B6D06E3BF92CADAFF289B3FCAEE CALL 38763251   90 38763251  1 OV2 
    3: D6941F85A1763F1F2D27B8F032D6411C86D4A5200512D65F381052C7D42BF57F CALL 40257471   63 40257471  1 OV3 
    4:        E768D36C813FD14157B06474F345EAFC SELECT 40897086   39475 40897086  1 OV4 
    5: 15873DB37BF80750C70B68A8778B9DC01D548B6D06E3BF92CADAFF289B3FCAEE CALL 40907760   57 40907760  1 OV2 
    6:        8067DE5FF5089BE6EC9D213F42525FC3 SELECT 40928334   29697 40928334  1 OV5 

我想以提取用於每個獨特(verb_object)適當的項目值將被表示爲跟隨一個數據幀:

> U1 

                  verb_object items 
           34D89F927092290A5DA9B108F7020C19 SELECT OV1 
15873DB37BF80750C70B68A8778B9DC01D548B6D06E3BF92CADAFF289B3FCAEE CALL OV2 
D6941F85A1763F1F2D27B8F032D6411C86D4A5200512D65F381052C7D42BF57F CALL OV3 
           E768D36C813FD14157B06474F345EAFC SELECT OV4 
           8067DE5FF5089BE6EC9D213F42525FC3 SELECT OV5 

回答

3

你可以簡單地做(好像是你有一個data.table作爲輸入,我注意到它dt):

unique(dt[,c("verb_object", "items"), with=F])