[Rd] Question on an alternative to ls() and expanded R object types

Thomas Lumley thomas@biostat.washington.edu
Thu, 29 Jun 2000 08:35:51 -0700 (PDT)


On Thu, 29 Jun 2000, Adrian Vance Custer wrote:
> 
> Would it be possible to improve R's listing ability by adding the capability
> to list objects by type, creation date, modification date, ancestry and/or
> user comments?

As you point out, the listing by type could be done in userspace.  The
comments could also be done this way, and you could add creation and
modification dates by hand this way or with simple functions like the
following, which adds a comment and the date it was made

addComment<-function(x,commment){
	cc<-attr(x,"comment")
	if (is.null(cc))
	    cc<-list()
	cc[[length(cc)+1]]<-paste(comment,date)
	attr(x,"comment")<-cc	
	x
	}	

showComments<-function(x){
	cc<-attr(x,"comment")
	if (is.null(cc)) 
	   return("No Comment")
        else
	   cc
	}
 
> Another luxury would be able to list the objects I've played with in the
> past few days. Since this facility doesn't exist I have to be exceedingly
> careful to remember the objects I have worked with recently. Similarly,
> when I derive an object from another, I currently have to remember the
> hierarchy. I am working mostly from a single large frame from which I
> extract various pieces. I modify these pieces to attempt an analysis or
> another but I must track both the objects and subobjects and the operations
> that happened along the way. I envison something like the call object in
> the model objects.  I suspect adding to each object its ancestry would
> take up a fair amount of space but I have no real sense of the memory
> requirements of such an addition.

The problem here is not so much the space, since Unix time and date
information can be stored in 32 bits (at least until 2038), but the
time.  Adding a creation time to every object would probably have serious
effects on the speed of R (in addition to the amount of work it would
take to implement). That's why it's probably better to just use comments.

Storing a pointer to the parents of an object would be a real pain (since
it would require keeping track of what objects were evaluated to do each
modification) and to do it properly would require keeping old versions of
the objects.

Something less general but more useful is probably to keep ESS transcripts
of sessions, which can then be replayed if the data changes. Some R
developers and others are interested in this sort of idea as 'Literate
Data Analysis' by analogy with Literate Programming.

	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._