Open
Conversation
Would previously zap the field names
DavisVaughan
approved these changes
Aug 19, 2020
Member
DavisVaughan
left a comment
There was a problem hiding this comment.
This looks correct to me! Do we care about indices? Maybe not right now? They are less useful than in vec-chop, I think.
| UNPROTECT(1); | ||
| } else { | ||
| // Zap inner names of atomic vectors. They become outer names. | ||
| out = PROTECT(vec_set_names(x, R_NilValue)); |
Member
There was a problem hiding this comment.
I think this can modify x in place if it isn’t referenced? Maybe capture the vec_names earlier to prevent issues if that is the case?
Member
Author
|
Right we can probably wait until there is a need for |
This was referenced Aug 19, 2020
Closed
Member
Author
Ah there's a feature request about this: #1164. |
This was referenced Jul 20, 2021
DavisVaughan
added a commit
to DavisVaughan/tidyr
that referenced
this pull request
Nov 4, 2021
Since we don't have `vec_chop2()` yet r-lib/vctrs#1226
DavisVaughan
added a commit
to DavisVaughan/tidyr
that referenced
this pull request
Nov 15, 2021
Since we don't have `vec_chop2()` yet r-lib/vctrs#1226
DavisVaughan
added a commit
to tidyverse/tidyr
that referenced
this pull request
Nov 15, 2021
* Implement `tidyr_chop2()` Since we don't have `vec_chop2()` yet r-lib/vctrs#1226 * Add `list_of_ptype()` helper for consistent list-of ptype extraction * Generalize `unchop_col_info()` into `list_init_empty()` This will be useful for an enhanced `simplify_col()` * Rename `tidyr_chop2()` to `tidyr_chop()` * Reimplement rectangling functions * NEWS bullet * Move details about `ptype` and `transform` to the `transform` param docs * Link to `list_of()` documentation * Mention recycling of `unnest_longer()` * Synchronize `values_to` and `indices_to` documentation * Replace "can't" with "must not" * Introduce `tidyr_temporary_new_list_of()` Because vctr objects can't currently have `""` names * Provide more input validation for `ptype` and `transform` * Add two tests about `names_sep`, provided by @mgirlich * Chop non-lists into lists with `vec_chop()` This uses more explainable vctrs tooling for converting non-primary data types (i.e. non-lists) into lists. This also seems to produce the expected output in more scenarios. Also inlined `tidyr_chop()` into `elt_to_wide()` since that is the only other place it was used. The fact that this removed a helper makes me optimistic that it is the right approach. * Test that df-cols result in list-ofs when `simplify = FALSE` * Apply unique name repair on names before applying `names_sep` Applying it before `names_sep` rather than after means that `""` and `NA_character_` names get repaired early on before they are combined with the prefix and `names_sep`, which can make them mistakently look like "valid" names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
vec_chop2()which is the[[equivalent ofvec_chop(). It is still unexported for now because we probably don't want to rush the "2" API but it will be useful internally for implementingvec_map().With atomic vectors it always transforms inner names into outer names:
Since we now require lists to have list storage, it just unstructures them:
Having this storage requirement really simplifies working with lists. We won't be able to support S4 lists like
S4Vectors::List()without introducing something likelist_proxy()andlist_unproxy()though.To make the implementation generic,
vctrs_rcrdnow supports assigningNULLnames. This also fixes a bug asnames<-would previously be applied to the fields. I still plan to add names support to rcrd vectors in the future but setting names to a character vector is an error for now.There is a new helper class for unit tests which is a record list that caches the sizes of its elements in attributes.