-
Notifications
You must be signed in to change notification settings - Fork 39
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
Tibble allows duplicate column names after rename(). #70
Comments
@krlmlr commented on Jul 21, 2018, 9:59 PM UTC: Thanks, confirmed. We shouldn't create duplicates here. |
@romainfrancois commented on Aug 13, 2018, 8:50 AM UTC: Is this a
We can be defensive in |
@lionel- commented on Aug 13, 2018, 9:03 AM UTC: It looks like it. |
What do you suggest that tibble should do about it? |
I'm suggesting that |
Thought this is a tibble issue now... 🤦♂️ 🤦♂️ |
There are times you might want duplicate names. For example, creating a tibble to pass to kable() or apa_table() in papaja. Let's say your table will show mean and CI of some outcome measures for treatment and control groups. Different measures are in rows of the table, named in column 1. Column 2 is mean for treatment, column 3 the CI for treatment, column 4 the mean for control, column 5 the CI for control. You're going to put column spans above the header row to denote treatment (cols 2 & 3) and control (cols 4 and 5). You'd want column 2 and 4 in the tibble to both be labelled 'Mean' and columns 3 and 5 to both be labelled '95% CI' because (and I could be wrong) in apa_table you can't override the variable names from the tibble you pass into it. Even if I'm wrong about that, it makes senseto have an option to override a default of no duplicate names IMO. |
@profandyfield You'd probably want to use nested tibbles in that case (i.e. a whole data frame in a column): tibble(
measure = c("foo", "bar"),
treatment = tibble(mean = 1:2, se = rnorm(2)),
control = tibble(mean = 3:4, se = rnorm(2))
)
#> # A tibble: 2 x 3
#> measure treatment$mean $se control$mean $se
#> <chr> <int> <dbl> <int> <dbl>
#> 1 foo 1 -0.453 3 -0.577
#> 2 bar 2 0.239 4 -1.18 |
move[bot] commented on Jul 21, 2018, 9:58 PM UTC:
@kovla commented on Jul 12, 2018, 9:35 AM UTC:
I imagine that
rename()
of a column to a name that already exists in the tibble (in another column) should warrant at least a warning. Otherwise it can result in two indistinguishable variables, with same name and type:This issue was moved by krlmlr from tidyverse/tibble#431.
This issue was moved by romainfrancois from tidyverse/dplyr#3723.
The text was updated successfully, but these errors were encountered: