Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有一个向量
tmp <- c("a", "a.b", "c", "c.g.g", "rr", "r.t")
我想找到索引或真/假,包括“。”
结果将是 2,4,6 或 FTFTTFT
我能怎么做?
您可以使用grepl和转义..
grepl
.
> tmp <- c("a", "a.b", "c", "c.g.g", "rr", "r.t") > grepl("\\.", tmp) [1] FALSE TRUE FALSE TRUE FALSE TRUE
你可以使用grep:
grep
grep(".", tmp, fixed=TRUE)