I want to compare each column of one dataframe with another dataframe column and print each resulting overlap to separate files.
I am executing the for loop to get the results:
for (i in colnames(df2)){
ccc<-df1[grep(paste(df2[,i], collapse = "|"), df1$x), ]
write.csv(ccc, file = paste(i, ".csv", sep=""))
}
But the above code is working for a small amount of dataset, if I pass a large amount of dataset then I am not getting the desired output.