Re: [R] Identify Objects that end with .f (and all caps)

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Sat, 14 May 2011 15:57:08 -0400

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"
>> temp2<-ls(pattern=\f)
> Error: unexpected input in "temp2<-ls(pattern=\"

You need to double the '\':

temp1<-ls(pattern="[A-Z]\\.f")

 > temp1
[1] "A.f" "AA.f" "NYSE.A.f"
>
> The end goal is to isolate A.f and AA.f and not the others.
> In terms of just getting the 'ending with .f' portion, I have tried a
> number of variations in the pattern=\f, but can't get R to recognize
> what
> I want.
>
> Your guidance would be much appreciated.
> --John J. Sparks, Ph.D.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> 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.

David Winsemius, MD
West Hartford, CT



R-help_at_r-project.org mailing list
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. Received on Sat 14 May 2011 - 20:00:12 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 14 May 2011 - 22:20:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive