[R] overlapping pattern match (errata 2.0)

FMGCFMGC FMGCFMGC at terra.es
Fri Mar 28 23:36:31 CET 2003


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



More information about the R-help mailing list