-
Notifications
You must be signed in to change notification settings - Fork 66
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
Review vec_is_list()
check on vec_proxy()
#1208
Comments
Probably best to use |
Summary of the main ideas:
|
Regarding how to implement For
It's going to be inefficient to update lists elements by elements, so it's always preferable to vectorise the assignment. |
Regarding a helper class for record lists and record data frames, I think |
#1226 adds a list record helper class for unit tests. #1228 implements |
@lionel- and I discussed the concept of a list-rcrd in more detail. Essentially this is a list that has some vectorized attributes that can get sliced alongside the list. We determined that one possible implementation of this idea is (in my own words):
The list itself is used as the core data structure.
The special vectorized attributes are stored as an attribute of the list. The easiest thing to do would be to store them as a named list in a single attribute called something like
vctrs:::vectorized
.The list explicitly inherits from
"list"
, along with whatever extra class is used on top of that. Say itsvctrs_list_rcrd
.The
vec_proxy.vctrs_list_rcrd
method should return a data frame. The first column is a list-col containing the list. The remaining columns are the vectorized attributes.This would currently work in vctrs, except for the fact that
vec_is_list()
has the following check: Ifx
inherits explicitly from"list"
, thenvec_proxy(x)
must also be a list. This should currently fail here (although I think it doesn't because of a bug).I don't remember exactly why we have that restriction, but it seems reasonable that we might try to remove it to allow these list-rcrds to work.
One possible implementation follows, but as @lionel- mentioned to me, the important part is that this doesn't require any vctrs specific helper, and can live completely outside vctrs.
Created on 2020-08-05 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: