[R] Count cases in a list
Sebastian Kruk
residuo.solow at gmail.com
Sat May 8 09:13:39 CEST 2010
Hi everybody, I would like to count how many times names in list L,
nombreL, apear in list C, nombreC.
Can I improve the next program?
cuenta <- 0
topL <- length(nombreL)
topC <- length(nombreC)
for (i in 1:topL) {
for (j in 1:topC) {
k <-
grep(noquote(nombreL[i]),nombreC[j])
if (length(k) > 0){
cuenta <- cuenta + 1
}
}
¿Is there a way to vectorizad?
Thanks,
Sebastián.
Saludos,
Sebastián.
More information about the R-help
mailing list