-
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
Expose vec_names2(), vec_names() and vec_set_names() #1173
Conversation
Needed for: - tidyverse/tibble#797 - tidyverse/tibble#738 - tidyverse/tibble#730 and perhaps more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs a NEWS bullet.
R/names.R
Outdated
#' Returns the repaired names from a vector, even if the vector is unnamed. | ||
#' @description | ||
#' These functions work like [rlang::names2()], [names()] and [names<-()], | ||
#' except that they return or modify the conceptual names of the vector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rowwise names of the vector. These are:
- The usual
names()
for atomic vectors and lists - The row names for data frames and matrices
- The names of the first dimension for arrays
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excuse the drive-by comment, but what is meant by "conceptual" names? If that term is defined and used elsewhere and I just don't have enough context, then never mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed this is not a defined term. I'm suggesting to replace "conceptual" by "rowwise", which seems clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since it is so related to the vctrs concept of size, they could be called "size consistent names"
R/names.R
Outdated
#' `vec_names()` is a bare-bones version that returns `NULL` if the vector is | ||
#' unnamed. | ||
#' | ||
#' `vec_set_names()` sets the names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a note that you can set names to NULL
to remove them?
Co-authored-by: Davis Vaughan <[email protected]> Co-authored-by: Lionel Henry <[email protected]>
Thanks for the feedback! |
#' Rowwise names are size consistent: the length of the names always equals | ||
#' [vec_size()]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks! |
Needed for:
and perhaps more.