You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could add arguments absolute = FALSE and verbose = interactive(), in addition to the existing prefix and sep arguments. This doesn't change the default behavior, but allows to replicate what readr does. Would that help?
It feels like the tidyverse should have a preferred remedy for nonexistent and duplicated column names. And tibble is currently the logical place to implement that. So I'd still like to reach a consensus across packages.
What do you think of exporting make_unique()? Sometimes you have the names before you have the object.
Perhaps my suggestion about leading underscores is not so bright. It creates non-syntactic names. I still think the convention should be something easily detectable via regex, i.e. unlikely to be present in original column names.
I expected sep to only be used during de-duplication.
x<-list(1:3,
var2=letters[1:3],
c(1, 2, 3) +0.1,
var2=letters[26:24])
names(x)[3] <-NAtibble::repair_names(tibble::as_data_frame(x, validate=FALSE),
prefix="__X", sep="__")
#> # A tibble: 3 脳 4#> `__X__1` var2 `__X__2` var2__1#> <int> <chr> <dbl> <chr>#> 1 1 a 1.1 z#> 2 2 b 2.1 y#> 3 3 c 3.1 x
I don't like the use of dots because it goes against the usual convention to use _. But I don't see a good alternative here, given that you can't start a syntactic name with _.
The way dplyr::rename() currently works, the names don't need to be syntactic. On the contrary, making them non-syntactic might encourage the user to use proper names as soon as possible, or to drop with select(-starts_with("__")).
I particularly like @jennybc's idea of simply appending the absolute position, without using V or X. I'm mildly concerned about backward compatibility, we might want to use pkgconfig to simplify transition from the old behavior.
Use .. as common prefix. I think it's the best compromise of ugliness and utility.
Show what transformation is happening (a la readr). We can add quiet = FALSE to suppress
Add a syntactic argument which, when TRUE, ensures that all names are syntactic
I'm not sure what we should do with respect to backward compatibility. I suspect few packages depend on this behaviour; it's going to be more user code. I think as long as there's a clear way to get to the old behaviour it shouldn't cause much hassle (especially since we're now describing what's happening)
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
Activity
krlmlr commentedon Feb 6, 2017
We could add arguments
absolute = FALSEandverbose = interactive(), in addition to the existingprefixandseparguments. This doesn't change the default behavior, but allows to replicate what readr does. Would that help?jennybc commentedon Feb 6, 2017
Yes, it certainly helps.
It feels like the tidyverse should have a preferred remedy for nonexistent and duplicated column names. And tibble is currently the logical place to implement that. So I'd still like to reach a consensus across packages.
What do you think of exporting
make_unique()? Sometimes you have the names before you have the object.hadley commentedon Feb 6, 2017
I'd like to make
repair_names()do what readr currently does so readr can just call it.I think it's probably a good idea to have two variants: one that works on a character vector of names, and the other that works on a named vector.
jennybc commentedon Feb 6, 2017
Perhaps my suggestion about leading underscores is not so bright. It creates non-syntactic names. I still think the convention should be something easily detectable via regex, i.e. unlikely to be present in original column names.
I expected
septo only be used during de-duplication.jimhester commentedon Feb 6, 2017
A leading
.would work for this and is not very likely to happen by chance, you can even use two..and still be syntactically valid.jennybc commentedon Feb 6, 2017
@jimhester Do you propose
.or..as the separator to be used for deduplication as well? Seems like a good idea.jennybc commentedon Feb 6, 2017
Moving towards a consensus on what should happen in current example:
Or we could decide whenever we incorporate a number, it refers to absolute column position
Even more consistent? Drop the
VorX.Now every name that needs repair simply gets
..jappended.jimhester commentedon Feb 6, 2017
FWIW I think the doubled identifiers are quite ugly, but I suppose that is part of the point...
jennybc commentedon Feb 6, 2017
Yeah, I think it is a feature if the repaired names are unsightly.
hadley commentedon Feb 6, 2017
I don't like the use of dots because it goes against the usual convention to use
_. But I don't see a good alternative here, given that you can't start a syntactic name with_.krlmlr commentedon Feb 7, 2017
The way
dplyr::rename()currently works, the names don't need to be syntactic. On the contrary, making them non-syntactic might encourage the user to use proper names as soon as possible, or to drop withselect(-starts_with("__")).I particularly like @jennybc's idea of simply appending the absolute position, without using
VorX. I'm mildly concerned about backward compatibility, we might want to usepkgconfigto simplify transition from the old behavior.hadley commentedon Feb 9, 2017
I think we should:
..as common prefix. I think it's the best compromise of ugliness and utility.quiet = FALSEto suppresssyntacticargument which, when TRUE, ensures that all names are syntacticI'm not sure what we should do with respect to backward compatibility. I suspect few packages depend on this behaviour; it's going to be more user code. I think as long as there's a clear way to get to the old behaviour it shouldn't cause much hassle (especially since we're now describing what's happening)
jennybc commentedon Apr 1, 2017
@krlmlr What's the outlook on this re: next tibble release?
krlmlr commentedon Apr 1, 2017
The next tibble release will have a better
repair_names(), but probably only after the next dplyr release.Merge pull request #248 from tidyverse/f-#217-tidy-names
Merge tag 'v1.3.0.9003'
Merge tag 'v1.3.1'
Switch to tibble::set_tidy_names() from tibble::repair_names()
Switch to tibble::set_tidy_names() from tibble::repair_names()
Switch to tibble::set_tidy_names() from tibble::repair_names()
Switch to tibble::set_tidy_names() from tibble::repair_names()
Switch to tibble::set_tidy_names() from tibble::repair_names()
Switch to tibble::set_tidy_names() from tibble::repair_names() (#453)
github-actions commentedon Dec 13, 2020
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.