Re: [R] use grep in lists and vectors

2014-01-12 Thread arun
Hi, May be this helps: mapply(grep,'^Ab$',test.list) #or lapply(test.list,function(x) grep("^Ab$",x)) A.K. On Sunday, January 12, 2014 9:31 PM, Hermann Norpois wrote: Hello, I want to detect Ab not Abc. For a normal vector test [1] "A"   "Ab"  "GG"  "GA"  "H"   "Abc" "Gz"  "HU" > grep ("

[R] use grep in lists and vectors

2014-01-12 Thread Hermann Norpois
Hello, I want to detect Ab not Abc. For a normal vector test [1] "A" "Ab" "GG" "GA" "H" "Abc" "Gz" "HU" > grep ("^Ab$", test) [1] 2 works well. For test.list [[1]] [1] "A" "Ab" "GG" "GA" [[2]] [1] "H" "Abc" "Gz" "HU" grep ("^Ab$", test.list) integer(0) doest not work. Why? How