>Date: Fri, 12 Jul 2002 08:35:26 -0700 (PDT) >From: Thomas Lumley <tlumley at u.washington.edu> >To: Patrick Connolly <p.connolly at hortresearch.co.nz> >cc: R-help <r-help at stat.math.ethz.ch> >Subject: Re: [R] R GUI and object browser >MIME-Version: 1.0 > >On Fri, 12 Jul 2002, Patrick Connolly wrote: >> >> >> I wrote my function some years ago and could do it much better knowing >> what I know now, but if someone wants to make something generally >> available, mine might be a good starting point. >> > >Interested parties might look at crossbreeding this with the object >browser in Bioconductor's tkWidget package.The tkWidget package is available at www.bioconductor.org under Downloads and then Released packages for a released version or Developmental packages for a development version. I have been working on and off the package and would be happy to discuss the possibility of crossbreeding if anyone is interested. JZ> > -thomas > > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html >Send "info", "help", or "[un]subscribe" >(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
As part of the obveRsive GUI project, we've written a function with much of the functionality that Patrick Connolly was suggesting (which is a bit more compact than the output from ls.str()). Alas, no date capabilities. The function is call ls.objects(), and example output appears below: Object.Name Object.Mode Object.Type Observations Variables 1 ccsest.df list data.frame 800 21 2 ccsval.df list data.frame 800 21 3 junkfactor numeric factor 100 1 4 junklist list unknown - - 5 junkmat numeric matrix 100 2 6 junkmodel list lm - - 7 ls.objects function function - - 8 orderdf function function - - 9 pkg character vector 1 1 10 stuff list data.frame 12 2 11 try numeric vector 100 1 12 try1 numeric vector 100 1 13 try2 numeric vector 100 1 14 trydat list data.frame 100 2 15 tryname character vector 1 1 The function has "mode" and "type" arguments (type is typically, but not always an object's class attribute). If the user only wants to list data.frames, then the command ls.objects(type="data.frame") will list only information for data.frames. The code itself follows below: __________________________________________________________ ls.objects <- function (pos = 1, pattern, mode = "any", type = "any"){ Object.Name <- ls(pos = pos, envir = as.environment(pos), pattern = pattern) Object.Mode <- rep("",length(Object.Name)) Object.Type <- rep("",length(Object.Name)) Variables <- rep("-",length(Object.Name)) Observations <- rep("-",length(Object.Name)) for (i in 1:length(Object.Name)){ Object.Mode[[i]] <- mode(get(Object.Name[[i]])) if(is.list(get(Object.Name[[i]]))){ if(is.null(class(get(Object.Name[[i]])))) Object.Type[[i]] <- c("unknown") else { Object.Attrib <- attributes(get(Object.Name[[i]])) Object.Type[[i]] <- Object.Attrib$class if(Object.Type[[i]]=="data.frame"){ Variables[[i]] <- as.character(length(Object.Attrib$names)) Observations[[i]] <- as.character(length(Object.Attrib$row.names)) } } } if(is.matrix(get(Object.Name[[i]]))){ Object.Attrib <- dim(get(Object.Name[[i]])) Object.Type[[i]] <- c("matrix") Variables[[i]] <- as.character(Object.Attrib[2]) Observations[[i]] <- as.character(Object.Attrib[1]) } if(is.vector(get(Object.Name[[i]])) && (Object.Mode[[i]]=="character" || Object.Mode[[i]]=="numeric")){ Object.Type[[i]] <- c("vector") Variables[[i]] <- c("1") Observations[[i]] <- as.character(length(get(Object.Name[[i]]))) } if(is.factor(get(Object.Name[[i]]))){ Object.Type[[i]] <- c("factor") Variables[[i]] <- c("1") Observations[[i]] <- as.character(length(get(Object.Name[[i]]))) } if(is.function(get(Object.Name[[i]]))) Object.Type[[i]] <- c("function") } objList <- data.frame(Object.Name,Object.Mode,Object.Type,Observations,Variables) if(mode != "any") objList <- objList[objList[["Object.Mode"]] == mode,] if(type != "any") objList <- objList[objList[["Object.Type"]] == type,] return(objList) } Hopefully this is what some of you were looking for. Dan Putler -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Mike, I agree that a date stamp would be generally useful, notwithstanding the issue to do with composite objects. I find it most useful when trying to track versions of functions I am developing and less so for imported data (they have their own external stamps) and less so for internally generated, often tempory, R data. I have affixed the following line just before the assign command in the 'fix' function which accesses my editor. attr(x,"date.modified")_date() and viewed using: attr(x,"date.modified") This fills a date.modified attribute to all information passing through the editor. I have modified the ls() function to display this date when listing R objects. Its not optimum but is a convenient fix for me. Regards Simon Gatehouse -----Original Message----- From: Mike Prager [mailto:mprager at alum.mit.edu] Sent: Friday, July 19, 2002 4:53 AM To: Patrick Connolly Cc: R-help Subject: Re: [R] R GUI and object browser At 09:54 AM 07/18/2002 +1200, Patrick Connolly wrote:>If hardly anyone agrees with me that the dates are useful to know, >it's certainly not worthwhile.For me (only 1 user), the dates would be welcome, but a low priority. An object browser would be useful, by which I mean something in a separate window. That would avoid constantly filling up the command (main) window and history with commands to recall the object names, which otherwise I am prone to forget (though probably not more so than any other 50+ year old). -- Mike Prager (mprager at alum.mit.edu) Beaufort, North Carolina -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._