Reputation: 21
Is there a way to compute how often a particular combination of numbers occurs in a vector?
Here is an example:
x <- 12348
y <- c(12348, 12348, 12348, 1234866, 1234586, 4444, 4444)
In the frequency count, I would like to include 1234866 and 1234586 as a match for 12348
So, in this case, the frequency of x in y should be 5
I tried different functions but was only able to get the frequency of exact matches.
Thanks a lot.
Upvotes: 1
Views: 67
Reputation: 887691
It may be better to use stringdist
library(stringdist)
sum(!stringdist(y, x, method = 'soundex') )
#[1] 5
Upvotes: 1