markfairbanks / tidytable

Tidy interface to 'data.table'
https://markfairbanks.github.io/tidytable/
Other
449 stars 33 forks source link

{vctrs} error when loading tidytable in .Rprofile #565

Closed mattsams89 closed 2 years ago

mattsams89 commented 2 years ago

So this is a bit of a weird one that popped up after the update to 0.8.1. I assume it has to do with base::%in% being masked when {tidytable} is loaded. If I load {tidytable} in my .Rprofile, RStudio's code completion errors out with the following:

Error:
! Can't combine <double> and <list>.
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/vctrs_error_incompatible_type>
Error:
! Can't combine <double> and <list>.
---
Backtrace:
 1. .rs.rpc.get_completions(...)
 2. .rs.acContextTypes$FUNCTION %in% type
 3. vctrs::vec_in(x, y)
 4. vctrs (local) `<fn>`()
 5. vctrs::vec_default_ptype2(...)
 6. vctrs::stop_incompatible_type(...)
 7. vctrs:::stop_incompatible(...)
 8. vctrs:::stop_vctrs(...)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/vctrs_error_incompatible_type>
Error:
! Can't combine <double> and <list>.
---
Backtrace:
    ▆
 1. └─.rs.rpc.get_completions(...)
 2.   └─.rs.acContextTypes$FUNCTION %in% type
 3.     └─vctrs::vec_in(x, y)
 4.       └─vctrs (local) `<fn>`()
 5.         └─vctrs::vec_default_ptype2(...)
 6.           └─vctrs::stop_incompatible_type(...)
 7.             └─vctrs:::stop_incompatible(...)
 8.               └─vctrs:::stop_vctrs(...)
 9.                 └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))

This doesn't happen if I load {tidytable} from the console once RStudio has started. I've tested this with both library(tidytable) and pacman::p_load(tidytable) with the same result.

For reference, my .Rprofile is pretty vanilla:

options(repos = "https://cloud.r-project.org")
cat("CRAN mirror set\n")

pacman::p_load(DBI, odbc, data.table, tidytable, glue)

`%notlike%` <- Negate(`%like%`)

dt <- tidytable::dt

*redacted DB stuff*

ETA the sessionInfo() for posterity's sake:

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

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] glue_1.6.2        tidytable_0.8.1   data.table_1.14.2 odbc_1.3.3        DBI_1.1.3        

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       fansi_1.0.3      utf8_1.2.2       lifecycle_1.0.1  magrittr_2.0.3   pacman_0.5.1    
 [7] pillar_1.8.1     rlang_1.0.4      cli_3.3.0        rstudioapi_0.13  blob_1.2.3       vctrs_0.4.1     
[13] ellipsis_0.3.2   tools_4.2.1      bit64_4.0.5      purrr_0.3.4      bit_4.0.4        hms_1.1.2       
[19] compiler_4.2.1   pkgconfig_2.0.3  tidyselect_1.1.2
markfairbanks commented 2 years ago

Reprex:

pacman::p_load(tidytable)

x <- c(1, 2, 3)
y <- list(1, 2)

x %in% y
#> Error:
#> ! Can't combine <double> and <list>.

#> Backtrace:
#>     ▆
#>  1. └─x %in% y
#>  2.   └─vctrs::vec_in(x, y)
#>  3.     └─vctrs (local) `<fn>`()
#>  4.       └─vctrs::vec_default_ptype2(...)
#>  5.         └─vctrs::stop_incompatible_type(...)
#>  6.           └─vctrs:::stop_incompatible(...)
#>  7.             └─vctrs:::stop_vctrs(...)
#>  8.               └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))
markfairbanks commented 2 years ago

I think it should be fixed now. Would you mind checking and letting me know if it worked?

mattsams89 commented 2 years ago

Yup, that seems to have fixed it!

markfairbanks commented 2 years ago

Awesome 👍

markfairbanks commented 2 years ago

@mattsams89 - if you happen to have any thoughts on #572 feedback is much appreciated (whether for or against 😄)