2

文のベクトルがあるとしましょう:

Vector
Juan is searching for a magazine.
Julia searched her car.
Go to the market to buy eggs.
Your name is unsearchable.
Search for me when you get to Paris.
Can you search for a low cost solution?

「検索」という単語またはそのバリエーション (つまり、検索済み、検索不能、検索) を含むエントリのみを含む、このベクトルのサブセットが必要です。Excelでは、「」という単語を含むISNUMBER(SEARCH("search",A1))列のセルを見つけるようなものを使用することがあります。A1search

それが私grepが探している機能のように思えますが、適切に使用する方法がわかりません。

4

1 に答える 1

5

vector指定した vertor の場合:

> grep("search", vector, ignore.case=TRUE)
[1] 1 2 4 5 6
> vector[grep("search", vector, ignore.case=TRUE)]
[1] "Juan is searching for a magazine."      
[2] "Julia searched her car."                
[3] "Your name is unsearchable."             
[4] "Search for me when you get to Paris."   
[5] "Can you search for a low cost solution?"
于 2013-01-15T23:27:19.327 に答える