On May 14, 2011, at 3:38 PM, Sparks, John James wrote:
Dear R Helpers,
I am trying to find a way to identify all the objects in my
environment
that are all caps and then end with .f. I can do the all caps part
pretty
easily, but I have tried a number of variations on the \ and can't
get a
recognition of that operator. As a simple example
A.f<-"foo1"
AA.f<-"foo2"
aa.f<-"foo3"
A.a<-"foo4"
ls()
[1] "A.a" "A.f" "aa.f" "AA.f"
temp1<-ls(pattern="[A-Z]")
temp1
[1] "A.a" "A.f" "AA.f"
Error: unexpected input in "temp2<-ls(pattern=\"
You need to double the '\':
temp1<-ls(pattern="[A-Z]\\.f")
[1] "A.f" "AA.f" "NYSE.A.f"