function to retrieve attributes from R objects
ofajardo opened this issue · 1 comments
It would be very nice to have a function to retrieve the attributes from R objects. This would be very useful for a lot of things, but here I described a couple I have found during these days: (EDIT: introducing check marks in those items that are solved)
-
Timestamp objects (POSIXct and POSIXlt) are always stored as UTC, but have an attribute for the timezone. If it is not null, R will use it to display the timestamp in that timezone. If NULL it will display the time in the local time zone of the user. As we cannot recover that attribute with librdata, we cannot display it as in R. Attached two files tstamp_GMT.RData and tstamp_nozone.RData each with a single vector POSIXct with a single member, with GMT time zone or without time zone as an example.
-
Matrices and Arrays data are read by librdata ,but the shape of those are stored in an attribute "dim". Without that it is not possible to shape the object in its original shape. Attached a file matrix.RData as an example.
-
ln addition to data frames, librdata can read Vectors, arrays and matrices. But as their class attribute is not known, one cannot cast them in the most adecquate data structure in another language. Attached a file tstamp_dataframe.RData in contrast to the files presented before. EDIT Now that dimensions can be read for these objects, it is actually irrelevant if they are a matrix, a table, on an array: all of them have to be casted to the same data structure.
-
Dataframes and matrices can have rownames, which are again stored as an attribute. Matrices can also have columnames, which again are in attributes. Attached a file mat_names.RData as an example of matrix with column and row names.
-
A bit unrelated, but it seems that librdata cannot read lists. Attached mylist.RData as an example.
Thanks!
- Another case: Date objects in R are actually integer vectors (number of days since Jan 1st 1970) with the attribute class set to "Date". librdata reads them as integer vectors, but not knowing the class makes it impossible to cast them to the appropiate date representation in another language. Another alternative for this one would be of course to parse the class type as it was done for POSIXct and POSIXlt.