[Rd] Suggestion: Dimension-sensitive attributes
Laurent Gautier
lgautier at gmail.com
Thu Jul 9 17:33:09 CEST 2009
Bengoechea Bartolomé Enrique (SIES 73) wrote:
> Forgot to answer this one:
>
>> It would seem natural that metadata associated with one dimension:
>> would a table-like object
[thanks for reading through what seems much like a telescoped sentences]
> Right. A data frame has the problem that for most use cases one would
> want that each dimension length matches the *rows* of the data frame
> instead of the columns, but it is the columns what we would have "for
> free" when allowing "dimmeta" elements to be lists...
Think of one data.frame per dimension and each data.frame having its
rows aligned along that dimension.
In the case of a matrix, the dim-1 data.frame would have as many rows as
rows in the matrix and the dim-2 data.frame would have as many rows as
columns in the matrix.
When thinking in terms of generalization, one can also note that the
one-dimension case can already be modelled by a data.frame.
L.
> Enrique
>
> -----Original Message----- From: Laurent Gautier
> [mailto:lgautier at gmail.com] Sent: jueves, 09 de julio de 2009 14:15
> Cc: Heinz Tuechler; Bengoechea Bartolomé Enrique (SIES 73); Tony
> Plate; Henrik Bengtsson; r-devel at r-project.org Subject: Re: [Rd]
> Suggestion: Dimension-sensitive attributes
>
> Starting by working on an interface for such object(s) is probably
> the first step toward a unified solution, and this before about if
> and how R attributes are used.
>
> It would also help to ensure a smooth transition from the existing
> classes implementing a similar solution (first the interface is added
> to those classes, then after a grace period the classes are
> eventually refactored).
>
> Dimension-level is what seems to the be most needed... but I am not
> convinced of the practicality of the object-level, and cell-level
> scheme s proposed:
>
> - Object-level, if not linked to any dimension-attribute is such
> saying that one want to attach anything to any object. That's what
> attr() is already doing.
>
> - Cell-level, is may be out-of-scope for one first trial (but may be
> I missed the use-cases for it)
>
>
>
> If starting with behaviour, it seems to boil to having "["/"[<-" and
> "dimmeta()"/"dimmeta<-()", :
>
> - extract "[" / replace "[<-" :
>
> * keeps working the way it already does
>
> * extracts a subset of the object as well as a subset of the
> dimension-associated metadata.
>
> * departing too much from the way "[" is working and add
> behind-the-curtain name matching will only compromise the chances of
> adoption.
>
> * forget about the bit about which metadata is kept and which one
> isn't when using "[". Make a function "unmeta()" (similar behavior to
> "unname()") to drop them all, or work it out with something like
>> dimmeta(x, 1) <- NULL # drop the metadata associated with dimension
>> 1
>
> - access the dimension-associated metadata:
>
> * may be a function called "dimmeta()" (for consistency with
> "dimnames()") ? The signature could be dimmeta(x, i), with x the
> object, and i the dimension requested. A replace function
> "dimmeta<-"(x, i, value) would be provided.
>
>
> In the abstract the "names" associated with a given dimension is just
> one of possible metadata, but I'd keep away from meddling with it
> for a start.
>
>
> It would seem natural that metadata associated with one dimension:
> would a table-like object (data.frame seems natural in R, and
> unfortunately there is no data.frame-like structure in R).
>
>
>
> L.
>
>
More information about the R-devel
mailing list