2

there is a vecter

tmp <- c("a", "a.b", "c", "c.g.g", "rr", "r.t")

i want find index or true/false including "."

the result will be 2,4,6 or F T F T F T

how can i do?

Rokmc1050
  • 463
  • 1
  • 6
  • 16

2 Answers2

4

You can use grepl and escape the ..

> tmp <- c("a", "a.b", "c", "c.g.g", "rr", "r.t")
> grepl("\\.", tmp)
[1] FALSE  TRUE FALSE  TRUE FALSE  TRUE
jdharrison
  • 30,085
  • 4
  • 77
  • 89
2

You could use grep:

grep(".", tmp, fixed=TRUE)
James Trimble
  • 1,868
  • 13
  • 20