[R] R GUI and object browser
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Wed Jul 17 08:39:06 CEST 2002
This may be appealing, but
1) R objects such as lists have shared components. You get the creation
date of the object, not of it components, and in any case I suspect you
want the last modification date.
2) Attributes are selectively copied (or not), so the effort needed to
change the code to preserve/update the attribute will be very considerable.
`Modifying functions that create list objects' includes all those which
3) User-written code would also need to be altered to preserve/update the
The only clean way I can see to do this would be to alter the internal
structure to store a creation date in a SEXPREC. That would add some
memory overhead (but less than attributes). It looks doable, but I remain
unconvinced it is worthwhile.
On Tue, 16 Jul 2002, Dan Putler wrote:
> Actually, it is fairly easy to give certain objects (those with a mode of
> "list", which includes data frames) a date attribute. This can be done
> either after creating a list object and then providing its date attribute, or
> (in at least some instances) by modifying the function that creates that
> object to include the date attribute assignment. The two functions needed to
> do this are the attr() and date().
> Here is an example of doing this after the fact:
> mydata <- data.frame(1:10,11:20)
> attr(mydata, "create.date") <- date()
> You can then get the value of the create.date attribute using the command
> Which will return a character string along the lines of
> "Tue Jul 16 22:12:05 2002"
> Moreover, my guess is that R functions that work on data frames will simply
> ignore the create.date attribute, or so my limited testing suggests.
> Modifying functions that create list objects often isn't hard either (although
> I don't know if this is always the case, but suspect it is). It turns out
> that the last two assignment statements of the data.frame() function are:
> attr(value, "row.names") <- row.names
> attr(value, "class") <- "data.frame"
> where "value" is the internal variable name for the data frame within the
> data.frame() function. If you modify the data.frame() function by adding the
> attr(value, "create.date") <- date()
> after the assignment of the "class", any data frames created using this
> function will have a create.date attribute.
> On Tuesday 16 July 2002 03:23 pm, Patrick Connolly wrote:
> > On Mon, 15-Jul-2002 at 01:13AM -0700, Dan Putler wrote:
> > |> 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.
> > My method of getting the dates is somewhat inelegant. However, it
> > could be simple if there was a date attribute of objects. Would such
> > a thing create an overhead that could be too burdensome for people who
> > don't have a use for it? Perhaps it could be one of the general
> > options that users could customize.
> > |> 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
> > This is certainly less complicated than my approach and does some
> > things mine doesn't.
> > best
> 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
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
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
More information about the R-help