Bug 15897 - index(): Extend names() functionality to allow non-character data types
Summary: index(): Extend names() functionality to allow non-character data types
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-07-23 07:45 UTC by naught101
Modified: 2014-07-23 07:45 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description naught101 2014-07-23 07:45:03 UTC
In python pandas, it is possible to use any scalar data type as an index on a dataframe (both for rows and columns, see http://pandas.pydata.org/pandas-docs/stable/indexing.html). This is particularly useful when using things like date-time as an index, as it allows really nice sub-setting and group-by ops. Also, allowing indexing by arbitrary integers, or POSIXct would allow some memory savings (as opposed to their character equivalents), and potentially a lot of computational savings, if the index no longer has to be converted between character and date types, for instance.

I was wondering if it might be possible to create an equivalent set to the names()-related functions (names<-() and rownames(), etc), called index() (index<-(), rowindex(), etc) that would allow vectors of any type, with other restrictions the same as names(). This would operate exactly the same as names(), with the index vector being stored as an attribute, and would actually be a super-set of names, in the sense that index() could also take character vectors. This would allow existing functionality to remain in place, and gradually be converted to index() later on (e.g. vector/dataframe displays could print indexes instead of names, if they existed).