well! excuse me again but... your.string <- "aaacdf" nc1 <- nchar(your.string)-1 x <- unlist(strsplit(your.string, NULL)) ######## CORRECT x2 <- c() for (i in 1:nc1) x2 <- c(x2, paste(x[i], x[i+1], sep="")) ######## ERRATA 2 cat("ocurrences of <aa> in <your.string>: ", length(grep("aa", x2)), sep="", fill=TRUE) Fran PD: sorry again