vctrs icon indicating copy to clipboard operation
vctrs copied to clipboard

Vectors in %in% Fails

Open latot opened this issue 8 months ago • 1 comments

Hi, I'm pretty new using vctrs, still I was able to do some basics in a lib, I'm mainly following https://vctrs.r-lib.org/articles/s3-vector.html#equality-and-comparison

Rn, I found that we can't use %in%:

node <- function(x) {
  vctrs::new_vctr(x, class = "node")
}

data <- node(c(1, 2, 3))

data[[1]] %in% data
Error in `as.character()`:
! Can't convert `x` <node> to <character>.
Run `rlang::last_trace()` to see where the error occurred.

Is this the right way to do it? or is a bug?

Thx!

latot avatar Dec 21 '23 15:12 latot

We should probably provide a definition for the new mtfrm() S3 generic if we can, used by match() and therefore %in%.

In the meantime you can use vctrs::vec_in() instead

DavisVaughan avatar Dec 21 '23 16:12 DavisVaughan