Skip to content
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

Error: Column name tidyr::nesting(...) must not be duplicated.... when using complete #822

Closed
wolski opened this issue Dec 3, 2019 · 10 comments

Comments

@wolski
Copy link

wolski commented Dec 3, 2019

After lately updating several packages including tidyr this code stopped working

library(tidyverse)
exdata <- readRDS(url("https://github.com/tidyverse/tidyr/files/3918551/exdata.zip"))
res <- tidyr::complete(
  exdata$data,
  tidyr::nesting(!!!syms(exdata$set1)),
  tidyr::nesting(!!!syms(exdata$set2))
)

and throws the follwing error:
Error: Column name tidyr::nesting(...) must not be duplicated. Use .name_repair to specify repair.

Just changing the order of the columns [c(5,1:4)] in second nesting directive makes it work again (why? - seems to me a spurious change which should not change the behaviour of complete).

res <- tidyr::complete(
  exdata$data,
  tidyr::nesting(!!!syms(exdata$set1)),
  tidyr::nesting(!!!syms(exdata$set2[c(5,1:4)]))
)
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] forcats_0.4.0   stringr_1.4.0   dplyr_0.8.3     purrr_0.3.3     readr_1.3.1    
[6] tidyr_1.0.0     tibble_2.1.3    ggplot2_3.2.1   tidyverse_1.3.0

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5 xfun_0.11        haven_2.2.0      lattice_0.20-38 
 [5] colorspace_1.4-1 vctrs_0.2.0      generics_0.0.2   htmltools_0.4.0 
 [9] rlang_0.4.2      pillar_1.4.2     withr_2.1.2      glue_1.3.1      
[13] DBI_1.0.0        dbplyr_1.4.2     readxl_1.3.1     modelr_0.1.5    
[17] lifecycle_0.1.0  cellranger_1.1.0 munsell_0.5.0    gtable_0.3.0    
[21] rvest_0.3.5      evaluate_0.14    knitr_1.26       callr_3.3.2     
[25] ps_1.3.0         broom_0.5.2      Rcpp_1.0.3       clipr_0.7.0     
[29] backports_1.1.5  scales_1.1.0     jsonlite_1.6     fs_1.3.1        
[33] hms_0.5.2        packrat_0.5.0    digest_0.6.23    stringi_1.4.3   
[37] processx_3.4.1   grid_3.6.1       cli_1.1.0        tools_3.6.1     
[41] magrittr_1.5     lazyeval_0.2.2   crayon_1.3.4     whisker_0.4     
[45] pkgconfig_2.0.3  zeallot_0.1.0    ellipsis_0.3.0   xml2_1.2.2      
[49] reprex_0.3.0     lubridate_1.7.4  assertthat_0.2.1 rmarkdown_1.18  
[53] httr_1.4.1       rstudioapi_0.10  R6_2.4.1         nlme_3.1-142    
[57] compiler_3.6.1  
@batpigandme
Copy link
Contributor

Do you mean for there to be two separate tidyr::nesting()s in there? If you use set1 and set2 in a single nesting() you get:

library(tidyverse)
exdata <- readRDS(url("https://github.com/tidyverse/tidyr/files/3918551/exdata.zip"))
res <- tidyr::complete(
  exdata$data,
  tidyr::nesting(!!!syms(exdata$set1), !!!syms(exdata$set2))
)

glimpse(res)
#> Rows: 100
#> Columns: 12
#> $ protein_Id                <chr> "A0AVT1", "A0AVT1", "A0AVT1", "A0AVT1", "A0…
#> $ peptide_Id                <chr> "ACIGDTLCQK", "FISADVHGIWSR", "GMITVTDPDLIE…
#> $ modPeptide_Id             <chr> "_AC[+57]IGDTLC[+57]QK_", "_FISADVHGIWSR_",…
#> $ precursor_Id              <chr> "_AC[+57]IGDTLC[+57]QK_~2", "_FISADVHGIWSR_…
#> $ isotope                   <chr> "light", "light", "light", "light", "light"…
#> $ filename                  <chr> "samon_D1807_098", "samon_D1807_098", "samo…
#> $ sampleName                <chr> "CMP/MEP~patient.HU.yes~PID282", "CMP/MEP~p…
#> $ celltype_                 <chr> "CMP/MEP", "CMP/MEP", "CMP/MEP", "CMP/MEP",…
#> $ class_therapy_progressed_ <fct> patient.HU.yes, patient.HU.yes, patient.HU.…
#> $ Patient_ID                <chr> "PID282", "PID282", "PID282", "PID282", "PI…
#> $ FG.Quantity               <dbl> 104890.961, 63959.547, 56562.879, 7808.923,…
#> $ EG.Qvalue                 <dbl> 9.568321e-04, 1.262353e-04, 5.092613e-04, 8…

Created on 2019-12-04 by the reprex package (v0.3.0.9001)

Adding backtrace for the code as you have it, above.

<error/tibble_error_column_names_must_be_unique>
Column name `tidyr::nesting(...)` must not be duplicated.
Backtrace:
  1. tidyr::complete(...)
  2. tidyr:::complete.data.frame(...)
  4. tidyr:::expand.data.frame(data, ...)
  5. tidyr::expand_grid(!!!cols, .name_repair = .name_repair)
  7. tibble:::as_tibble.list(out, .name_repair = .name_repair)
  8. tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x))
  9. tibble:::set_repaired_names(x, .name_repair)
 14. tibble:::repaired_names(...)
 15. tibble:::subclass_name_repair_errors(...)
 16. base::tryCatch(...)
 17. base:::tryCatchList(expr, classes, parentenv, handlers)
 18. base:::tryCatchOne(...)
 19. value[[3L]](cond)

@wolski
Copy link
Author

wolski commented Dec 4, 2019

@batpigandme NO

@batpigandme
Copy link
Contributor

Ok, I'm gonna go ahead and close this issue, then. Let me know if I've misunderstood.

@wolski
Copy link
Author

wolski commented Dec 4, 2019

Yes you missunderstood.

@batpigandme batpigandme reopened this Dec 4, 2019
@batpigandme
Copy link
Contributor

batpigandme commented Dec 4, 2019

Ok. Can you please expand on what you mean, then? What's your expected output?

Do you mean for there to be two separate tidyr::nesting()s in there?

@batpigandme No

@wolski
Copy link
Author

wolski commented Dec 4, 2019

NO - the issue is not me using two nesting statements! The issue is that the code as posted in the first snipped does not work - and I can't see a reason why it should not work as it is (but this is clearly stated in my first post I believed - and did't I state that it was working with a pre 1.0 version of tidyr?). The expected output is that the first code snipped works, that it does not throw an error (obviously), and that the output is equal (what might be different is the column order) to the result of code snipped 2, which does still work.

@hadley
Copy link
Member

hadley commented Dec 4, 2019

@wolski I can tell that you are frustrated but that does not make it ok to be rude. It is hard to tell what you are trying to achieve, and @batpigandme has been trying to help figure out exactly what the problem is.

@wolski
Copy link
Author

wolski commented Dec 5, 2019

@hadley This is unfair! I am also trying to help. All I was asking is why code, which I think should work does not. I invested quite a bit of time creating the issue, testing the code, included a reprex and even an example where it works.

@hadley
Copy link
Member

hadley commented Dec 5, 2019

@wolski responding "NO" to an attempt to help comes across as very rude. I can see that you have put some time in to this issue, but you have failed to explain it to us in a way we understand. I am going to close this issue to give every one time to cool off; please feel free to open a new one next week.

@hadley hadley closed this as completed Dec 5, 2019
@wolski
Copy link
Author

wolski commented Dec 5, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants