Skip to content
Prev 318922 / 398521 Next

How to combine conditional argument and logical argument in R to create subset of data...

Hi,
I am not sure I understand it correctly.



In the example you gave, there are duplicated rows in Tem1, ie. (222 6 ), (222 7), (333 11), but these rows are also present in Tem2
Is there any chance of triplicates etc..
Also, you wanted to have rows that are not common in Tem1 and Tem2. ie. (111 1) is the first row in both.
indxTem1<-paste0(Tem1[,1],Tem1[,2])
?indxTem2<-paste0(Tem2[,1],Tem2[,2])


?res<-rbind(Tem1[!indxTem1%in%indxTem2,], Tem1[duplicated(Tem1),]) 
res
res
?????? V1 V2
# [1,] 333 12
?#[2,] 111 16
?#[3,] 111 17
?#[4,] 111 20
?#[5,] 222 21
?#[6,] 222 22
?#[7,] 222 23
?#[8,] 333? 4
?#[9,] 333? 5
#[10,] 333? 6
#[11,] 333? 7
#[12,] 222? 6
#[13,] 222? 7
#[14,] 333 11

In cases of more replicates (triplicates, etc...) how do you want to process.? Also, here the duplicate rows were found only in Tem1.
A.K.