I have a very large table (1,000,000 X 20) to process and need to do it in a fast way.
For example, There are 2 columns X2 and X3 in my table:
X1 X2 X3
c1 1 100020003001, 100020003002, 100020003003 100020003001, 100020003002, 100020003004
c2 2 100020003001, 100020004002, 100020004003 100020003001, 100020004007, 100020004009
c3 3 100050006003, 100050006001, 100050006001 100050006011, 100050006013, 100050006021
Now I would like to create 2 new columns which contain
1) the common words or the same numbers
For example: [1] "100020003001" "100020003002"
2) the count of the common words or the same numbers
For example: [1] 2
I have tried the method from the below thread, however, the processing time is slow since I did it with for loop:
Count common words in two strings
library(stringi)
Reduce(`intersect`,stri_extract_all_regex(vec1,"\\w+"))
Thanks for the help! I am really struggling here...