[R] matching strings in a list

John McKown john.archie.mckown at gmail.com
Thu Jul 16 20:01:54 CEST 2015


On Thu, Jul 16, 2015 at 1:00 PM, John McKown <john.archie.mckown at gmail.com>
wrote:

> On Thu, Jul 16, 2015 at 12:40 PM, tryingtolearn <inshique at ymail.com>
> wrote:
>
>> Say I have a list:
>> [[1]] "I like google"
>> [[2]] "Hi Google google"
>> [[3]] "what's up"
>>
>> and they are tweets. And I want to find out how many tweets mention google
>> (the answer should be 2).
>> If I string split and unlist them, then I would get the answer of 3. How
>> do
>> I make sure I get just 2?
>>
>
> ​NROW(grep("google",list,ignore.case=TRUE))​
>

​Or

sum(grepl("google",x,ignore.case=TRUE))

-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

	[[alternative HTML version deleted]]



More information about the R-help mailing list