Hi Neha,
How about this?
find_subset<-function(x,y) {
yrows<-dim(y)[1]
match<-0
for(row in 1:yrows) match<-sum(x&y[row]) >= sum(y[row])
return(match)
}
apply(B,1,find_subset,A)
This is somewhat obscure, as the dataframe B is coerced to a matrix by
the apply function.
Jim
On Sat, Apr 21, 201
Hi Neha,
How about this?
A <- as.matrix(A)
B <- as.matrix(B)
C <- A %*% t(B)
SA <- apply(A, MAR=1, sum )
SB <- apply(B, MAR=1, sum )
vapply( 1:nrow(B), function(j) { sum( C[,j]==SA & SA <= SB[j] ) > 0 }, 1 )
HTH,
Eric
On Sat, Apr 21, 2018 at 10:27 AM, Neha Aggarwal
wrote:
> Hi,
>
> I am
Hi,
I am looking for a way in which I can check if rows in 1 dataframe are
present in another data frame in a unique way. A row in dataframe should be
super set of any row in another dataframe.
I can write a for loop for it, however, that will be inefficient. So, I am
looking for an efficient way
3 matches
Mail list logo