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

Have some code which uses tidyr::complete and tidyr::nesting. After recent package updates this code with data it was workign before starts to throw errors.

tidyr::complete(
+     data ,
+     tidyr::nesting(!!!syms(c(config$table$hierarchyKeys(), config$table$isotopeLabel))),
+     tidyr::nesting(!!!syms(c(config$table$fileName , config$table$sampleName, config$table$factorKeys() )))
+   )
Error: Column name `tidyr::nesting(...)` must not be duplicated.
Use .name_repair to specify repair.
> c(config$table$hierarchyKeys(), config$table$isotopeLabel)
[1] "protein_Id"    "peptide_Id"    "modPeptide_Id" "precursor_Id"  "isotope"    

 c(config$table$fileName , config$table$sampleName, config$table$factorKeys() )
[1] "filename"                  "sampleName"                "celltype_"                 "class_therapy_progressed_" "Patient_ID"

are valid column names afaik and are present in data.

Tried to work out what the error might be but all seems fine.

expand does not complain

 expand(data,  tidyr::nesting(!!!syms(c(config$table$hierarchyKeys(), config$table$isotopeLabel))))
# A tibble: 63,964 x 5
 expand(data,  tidyr::nesting(!!!syms(c(config$table$fileName , config$table$sampleName, config$table$factorKeys() )))
+ )
# A tibble: 50 x 5
...

And there is not intersection among the two lists of column names.

i> intersect(c(config$table$fileName , config$table$sampleName, config$table$factorKeys() ), c(config$table$hierarchyKeys(), config$table$isotopeLabel))
character(0)

Help would be greatly appreciated.

> 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    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      tidyr_1.0.0      tibble_2.1.3     ggplot2_3.2.1    tidyverse_1.3.0  readr_1.3.1      LFQService_0.1.5

loaded via a namespace (and not attached):
 [1] fastcluster_1.1.25 tidyselect_0.2.5   haven_2.2.0        lattice_0.20-38    colorspace_1.4-1   vctrs_0.2.0        generics_0.0.2     rlang_0.4.2        pillar_1.4.2      
[10] withr_2.1.2        glue_1.3.1         DBI_1.0.0          dbplyr_1.4.2       RColorBrewer_1.1-2 ggfortify_0.4.8    modelr_0.1.5       readxl_1.3.1       lifecycle_0.1.0   
[19] munsell_0.5.0      gtable_0.3.0       cellranger_1.1.0   rvest_0.3.5        heatmap3_1.1.6     broom_0.5.2        Rcpp_1.0.3         backports_1.1.5    scales_1.1.0      
[28] jsonlite_1.6       fs_1.3.1           gridExtra_2.3      hms_0.5.2          packrat_0.5.0      stringi_1.4.3      grid_3.6.1         cli_1.1.0          tools_3.6.1       
[37] magrittr_1.5       lazyeval_0.2.2     crayon_1.3.4       pkgconfig_2.0.3    zeallot_0.1.0      ellipsis_0.3.0     pheatmap_1.0.12    xml2_1.2.2         reprex_0.3.0      
[46] lubridate_1.7.4    assertthat_0.2.1   httr_1.4.1         rstudioapi_0.10    R6_2.4.1           nlme_3.1-142       compiler_3.6.1   

Hi!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

The key of a reprex is that other people need to be able to reproduce the problem. :slightly_smiling_face: Right now no one else has your data so no one can help you troubleshoot and test different things.

Adding an example of your dataset will be a good start. For example, you could copy and paste the output of dput(data) or, if that's too big, dput(head(data)). You could also write out the character vectors you are using in nesting() so they can be copied and pasted since we don't have config. Then folks will be able to actually run your code and try to help you come up with a solution. :+1:

I encountered it with this data only. The data is 1GB in size and I can't share it anyway. Would by happy to provide a smaller example but can't.

Still a more experienced user than me or you two asking for an reprex could point me to the problem looking at the error message.

Came up with an reprex, although I am rather inclined to think now that this an "issue" to be posted on github (did I mention that this code was working with older versions of tidyr?

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))
)

Just changing the order of the columns [c(5,1:4)] in second nesting directive makes it work.

res <- tidyr::complete(
  exdata$data,
  tidyr::nesting(!!!syms(exdata$set1)),
  tidyr::nesting(!!!syms(exdata$set2[c(5,1:4)]))
)

Posting it to github.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.