r-lib / rray

Simple Arrays
https://rray.r-lib.org
GNU General Public License v3.0
130 stars 12 forks source link

More fexible dimnames #248

Open eliocamp opened 4 years ago

eliocamp commented 4 years ago

From this twitter conversation.

It would be neat for dimnames not to be limited to character vectors. This would be helpful for gridded data (similar to data cubes).

I don't know enough about R internals to know how this would fare in terms of compatibility with base arrays, though.

juangomezduaso commented 4 years ago

Perhaps an interesting and useful object to have could be a new version of tbl-cube which had dataframes instead of just character vectors as its "dimensions". This is something already pointed out in a tbl-cube´s code comment. We have used this idea for the representation in R of the multidimensional aggregated data we have in our Institute (www.ige.eu). So, this object would have a list of N-dimensional rrays ("measures") and a list of N dataframes each with nrow() equal to the dim() in that axis. The usefullness of this being to allow the integrity of subseting operations, taking into account the rrays and dataframes at a time. Obviously, this object would solve the aim of this issue as a particular case of one column (of any arbitrary type) dataframe "dimensions". I had some reserves about tblcube being too constraining (as I tried to explain in https://github.com/tidyverse/dplyr/issues/4429#issuecomment-510206305 ). It seemed to me to imply that arithmetic calculations should happen inside a tbl-cube or in other case two tbl-cubes would need to be tediously joined in advance. But now I think that it was a missconception on my part, and that it is not incompatible to be a "measure" of one of these new-tb-cubes and be able to perform arithmetic against any other rray (bradcasting included).

eliocamp commented 4 years ago

Yes, absolutely. That would be awesome.