[R] grep command

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue May 3 15:05:27 CEST 2016


Isn't that just an inefficient way to do

"age" == x

?
-- 
Sent from my phone. Please excuse my brevity.

On May 3, 2016 3:57:05 AM PDT, Ivan Calandra <ivan.calandra at univ-reims.fr> wrote:
>What about?
>
>grep("^age$", x)
>
>Ivan
>
>--
>Ivan Calandra, PhD
>Scientific Mediator
>University of Reims Champagne-Ardenne
>GEGENAA - EA 3795
>CREA - 2 esplanade Roland Garros
>51100 Reims, France
>+33(0)3 26 77 36 89
>ivan.calandra at univ-reims.fr
>--
>https://www.researchgate.net/profile/Ivan_Calandra
>https://publons.com/author/705639/
>
>Le 03/05/2016 à 12:38, Steven Yen a écrit :
>> Dear all
>> In the grep command below, is there a way to identify only "age" and
>> not "age2"? Thanks.
>>
>>> x<-c("abc","def","rst","xyz","age","age2")
>>> x
>> [1] "abc"  "def"  "rst"  "xyz"  "age"  "age2"
>>> grep("age2",x)
>> [1] 6
>>> grep("age",x) # I need to grab "age" only, not "age2"
>> [1] 5 6
>>
>> Also, I post message to r-help at r-project.org and that's subject to
>> approval by the list moderator. Am I sending it to the wrong address?
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list