Skip to content
Prev 4036 / 63421 Next

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

On Thu, 29 Jun 2000, Adrian Vance Custer wrote:
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
	}
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._