2

Binding two tribbles

library(tidyverse)


dplyr::tribble(
  ~comp, ~val,
  "g", 100
) %>% 
  dplyr::bind_rows(
    dplyr::tribble(
      ~comp, ~val,
      "h", 100
    )
  )

results in the following error

Error in `vec_size()`:
! `x` must be a vector, not an environment.

This is not a result of masking:

> tidyverse_conflicts()
── Conflicts ─────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()

with this sessionInfo()

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 25211)

Matrix products: default

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

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

other attached packages:
 [1] lubridate_1.8.0      forcats_0.5.2        stringr_1.4.1        dplyr_1.0.99.9000   
 [5] purrr_0.9000.0.9000  readr_2.1.3          tidyr_1.2.1          tibble_3.1.8        
 [9] ggplot2_3.3.6        tidyverse_1.3.2.9000

loaded via a namespace (and not attached):
 [1] rstudioapi_0.14       magrittr_2.0.3        hms_1.1.2             tidyselect_1.1.2.9000
 [5] munsell_0.5.0         colorspace_2.0-3      R6_2.5.1              rlang_1.0.6          
 [9] fansi_1.0.3           tools_4.2.1           grid_4.2.1            gtable_0.3.1         
[13] utf8_1.2.2            cli_3.4.1             withr_2.5.0           ellipsis_0.3.2       
[17] lifecycle_1.0.2.9000  crayon_1.5.2          tzdb_0.3.0            vctrs_0.4.2.9000     
[21] glue_1.6.2            stringi_1.7.8         compiler_4.2.1        pillar_1.8.1.9000    
[25] generics_0.1.3        scales_1.2.1          pkgconfig_2.0.3      
tomw
  • 3,114
  • 4
  • 29
  • 51
  • under which loaded libraries? – tomw Oct 06 '22 at 13:20
  • just the tidyverse – GuedesBF Oct 06 '22 at 13:21
  • 2
    You've likely masked `tribble` or `bind_rows` as its own environment. If you restart your R session, I bet this will work for you. – Matt Oct 06 '22 at 13:21
  • @Matt --no, I ran `tidyverse_conflicts` and returned no relevant masks – tomw Oct 06 '22 at 13:23
  • @tomw I think `tidyverse_conflicts()` checks namespace conflicts in packages only and does not extend to your global environment. I would try explicitly referencing dplyr functions (i.e., `dplyr::tribble(~blah...) %>% dplyr::bind_rows()`) – Matt Oct 06 '22 at 13:34
  • @Matt adding `dplyr::tribble` does not solve the problem – tomw Oct 06 '22 at 13:41
  • 3
    It's because you're using the development version of `dplyr` - I couldn't reproduce your issue but then noticed you were using the dev version so I installed it and could reproduce. Re-installing the CRAN version should fix the issue. – Ritchie Sacramento Oct 06 '22 at 13:48
  • 2
    Adding to @RitchieSacramento's comment ... I suggest you submit this as a [bug report](https://github.com/tidyverse/dplyr/issues/new/choose). – r2evans Oct 06 '22 at 13:56
  • @Matt - Ritchie had the right answer. Always nice to find an actual bug! – tomw Oct 06 '22 at 13:58

0 Answers0