[R] grep and strings
Spencer Graves
spencer.graves at pdf.com
Tue Apr 27 02:06:12 CEST 2004
How about the following:
> tst <- c(".a.", "asdf")
> sum(regexpr("\\.a\\.", tst)>0)
[1] 1
hope this helps. spencer graves
K Fung wrote:
>I have the following command:
>
>length(
> grep("\.a\.", names(temp)))
>
>where temp is a vector with names
>
>I want to count the number of entries that contain the
>sequence of characters ".a.". However, R seems to
>return all entries that contain "a" (every entry
>contains "." in this example).
>
>How should I fix this? Thanks
>
>
>__________________________________
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list