[R] help with generalized list function in R

About this list Date view Thread view Subject view Author view Attachment view

From: Andrew White (andrew_white@hmsa.com)
Date: Thu 13 May 2004 - 07:15:46 EST


Message-id: <8B9604D41941A14F90E094B07713F953027D0E02@HON10036.corp.hmsa.com>

In S-plus I have depended upon a simple extended ls() function developed by John wallace called lsx()

Reason: lsx() allows me to search for object names in my local workspace matching an unquoted character string.
Since I forget all the function names or data object names I have added, I can quickly find any/all names matching any specified string.

BUT: the lsx() function when installed (successfully, no errors reported) in R does not work in R.
Why ? Can it be fixed so it can work?

Code is below:
---------------------------
lsx<-function(pattern, pos = 1, wild = T, long = F, mode = "function")
{
        # lsx = extended listing: pattern match on quoted string, incl wildcards
        #
        # LS-eXtended (saved as ls3.s): list objects all or matching <pattern>
        # DATE WRITTEN: February 1995 LAST REVISED: 15 August 1995
        # AUTHOR: John R. Wallace (jw@u.washington.edu)
        #
        if(!missing(pattern)) {
                if(!is.character(substitute(pattern, frame = sys.nframe())))
                        pattern <- deparse(substitute(pattern, frame = sys.nframe()))
                if(wild)
                        pattern <- paste("*", pattern,"*", sep = "")
                if(!(substring(as.character(version)[1], 2, 4) == "WIN"))
                        pattern <- pat2grep(pattern)
                if(long)
                        print(out <- objects.summary(objects(pos, pat = pattern), where = pos))
                else print(out <- objects(pos, pat = pattern), q = F)
        }
        else {
                if(long)
                        print(out <- objects.summary(where = pos, mode = mode))
                else {
                        if(substring(as.character(version)[1], 2, 4) == "WIN") {
                                pattern <- "[!.]*"
                                print(out <- objects(pos, pat = pattern), q = F)
                        }
                        else {
                                all <- objects(pos)
                                print(out <- all[!match(all, objects(pos, pat = "^\\."),no = 0)], q = F)
                        }
                }
        }
        invisible(out)
}

---------------------------

Andy White
Andrew N. White, Ph.D. - Manager Research Unit
Financial Reporting & Medical Economics Dept.
Hawaii Medical Service Association
- Blue Cross Blue Shield of Hawaii
An Independent Licensee of the Blue Cross and Blue Shield Association -
818 Keeaumoku Street, Honolulu, HI 96814
Ph. 808-948-5344 - Email: andrew_white@hmsa.com

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:09 EST