-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Vectors in base::data.frame #61
Comments
Any chance that if I prepare a PR to add the following functions has a chance to succeed?
One possible problem I can imagine is that some base data.frame manipulators can get fussy about S4 columns. For example:
The |
A |
You're right the |
Following from the recent discussion on the Bioconductor Slack, it would seem that base R
data.frame
classes are able to support S4 objects as columns. Below is a quick proof of principle:Created on 2020-01-27 by the reprex package (v0.3.0)
I'm submitting this issue to serve as a discussion ground about possible ways to integrate S4Vectors derived classes more seamlessly into base R
data.frame
s, in particular vector- and list-like classes that are linear but not rectangular in nature. Here are two ideas that would make that easier.As mentioned by @hpages on slack, it would be neat to have
format()
methods such that base Rdata.frame
s print more nicely with S4Vectors inheritors, similar to how theshowAsCell
generic handles printing ofDataFrame
s.The
data.frame(...)
constructor internally callsas.data.frame()
on every element in...
. As an example, theRle
class coerces/expands to a regular vector during that procedure, whereas it would also be nice if users could have an option to preserve the S4 class duringdata.frame
construction. This would prevent having to resort to the awkward syntax in the example above. An alternative constructor that does this would fit the bill, as repurposing theas.data.frame
generic probably would break a lot of existing code.I'm sure there are other places where some compatibility with base R data.frames could be achieved, but these would be a neat start.
The text was updated successfully, but these errors were encountered: