I have two data. Frame x1 & amp; X2. I want to remove rows from x2 there is a common found genes x1 and x2
x1 & lt, - chr started late gene 1 8401 8410 Mndal, Mnda, Ifi203, Ifi202b 2 8001 8020 Cyb5r1 , Adipor1, Klhl123 40014020 Alyref2, Itln1, CD244x2 & lt; - chr started late gene 1 8861 8868 Olfr1193 1 8405 8420 Mrgprx3-ps, Mrgpra1, Mrgpra2a, Mndal, Mrgpra2b 2 8501 8520 Chia, Chi3l3, Chi3l4 3 4321 4670 Tdpoz4, Tdpoz3, Tdpoz5 x2 & lt; - chr started late gene 1 8861 8868 Olfr1193 2 8501 8520 Chia, Chi3l3, Chi3l4 3 4321 4670 Tdpoz4, Tdpoz3, Tdpoz5
, Strsplit (2 x $ genes, '')) # # early end Jean # 2 2 8501 8520 Chia, Chi3l3, Chi3l4 # 3 3 4321 4670 Tdpoz4, Tdpoz3, Tdpoz5
Or to change! == 0
with any (x% x%) length (intersection (x, y)). Note: If the "gene" column is "factor", then it can not take the 'factor' class as "code" in the form of "code" strsplit
. I.e. strsplit (as.character (x1 $ gene ','))
update
Based on the new dataset for 'x2', we Can be merged into both the datasets, strsplit
'Genes.x', 'Genes.y', merge from production dataset ('xNew') into the merge
'chr' column. (X1 -; logical indices 'Genes.y' is based on the occurrence of any element of 'Genes.x' in the string, that the use of 'x2' dataset subsets
xNew & Lt x 2 [, c (1,4)], by = 'CRR' index and lieutenant; - mappily (function (x, y) Isi also (x% of% y), Strsplit (Aksani $ Jen.aks, ','), Strsplit (xNew $ Genes.y, ',')) x2 [! Indx,] # chr started late Gene # 1 1 8861 8868 Olfr1193 # 3 2 8501 8520 Chia Chi 3L 3, Chi 3L 4 # 4 3 4321 4670 Teedeepijh 4, Teedeepijh 3, Tdpoz5