Hello,
Where is the reproducible example?
apricum wrote>
> Hi,
> I need to find number of occurence of each word from one string in other
> string. So I need a function, which is similar to pmatch, but returns not
> references, but number of matches. Is there any function like this? If
> no, that is the way to calculate what I need?
>
Anyway, this might help.
set.seed(1)
x <- paste(sample(letters[1:4], 10, T), collapse = " ")
x
x2 <- unlist(strsplit(x, " "))
xmatch <- pmatch(x2, c("auvw", "bxyz"), duplicates.ok =
TRUE)
# Several ways to count matches
tapply(xmatch, xmatch, length)
aggregate(xmatch, list(xmatch), length)
by(xmatch, xmatch, length)
Rui Barradas
--
View this message in context:
http://r.789695.n4.nabble.com/Count-matches-in-pmatch-tp4439722p4440316.html
Sent from the R help mailing list archive at Nabble.com.