# What is Julia's equivalent of R's %in%

**URL:** <https://discourse.julialang.org/t/what-is-julias-equivalent-of-rs-in/28720>\
**Category:** New to Julia\
**Created:** [September 13, 2019, 2:21pm UTC](https://discourse.julialang.org/t/what-is-julias-equivalent-of-rs-in/28720 "2019-09-13T14:21:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 14, 2019, 6:02pm UTC](https://discourse.julialang.org/t/what-is-julias-equivalent-of-rs-in/28720/4 "2019-09-14T18:02:09Z")

</div>

cf

> [@Julia's in.() seems slow compared to R's %in%](https://discourse.julialang.org/t/julias-in-seems-slow-compared-to-rs-in/23900):
>
> Hi everyone, I want to compare if elements of vector x are in elements of vector y. In R, I can do this as follows: \> x \<- c("a", "b", "c") \> y \<- c("b", "a") \> x %in% y [1] TRUE TRUE FALSE In Julia, I can do this as follows: julia\> x = ["a", "b", "c"]; julia\> y = ["b", "c"]; julia\> in.(x, Ref(y)) 3-element BitArray{1}: false true true Now let’s make the vector big: In R, \> set.seed(123) \> x \<- rnorm(100000, 1000, 2) \> y \<- rnorm(100000, 1000, 2) \> system.time(x %in% y) user sy…

TL;DR: you are probably looking for

```julia
x .∈ Ref(Set(y))

```

---

_[View the full topic](https://discourse.julialang.org/t/what-is-julias-equivalent-of-rs-in/28720)._
