[R] overlapping pattern match (errata)

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


hello again!

there is an error in my previous post:

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(x2[i], x2[i+1], sep=""))
cat("ocurrences of <aa> in <your.string>:", length(grep("aa", x2)),
 sep="", fill=TRUE)

Hope it helps!
Fran



More information about the R-help mailing list