Bug 15897

Summary: index(): Extend names() functionality to allow non-character data types
Product: R Reporter: naught101 <naught101>
Component: WishlistAssignee: R-core <R-core>
Status: NEW ---    
Severity: enhancement    
Priority: P5    
Version: R-devel (trunk)   
Hardware: All   
OS: All   

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).