# Julia equivalent to R %in%

**URL:** <https://discourse.julialang.org/t/julia-equivalent-to-r-in/21138>\
**Category:** General Usage\
**Created:** [February 24, 2019, 12:00pm UTC](https://discourse.julialang.org/t/julia-equivalent-to-r-in/21138 "2019-02-24T12:00:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Graham\_W\_Griffiths](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Graham\_W\_Griffiths](https://discourse.julialang.org/u/Graham_W_Griffiths)\
**Post date:** [February 24, 2019, 12:00pm UTC](https://discourse.julialang.org/t/julia-equivalent-to-r-in/21138/1 "2019-02-24T12:00:02Z")

</div>

I am trying to find the Julia equivalent to the R statement:

`which(A %in% B)`

Any help appreciated

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [February 24, 2019, 12:40pm UTC](https://discourse.julialang.org/t/julia-equivalent-to-r-in/21138/2 "2019-02-24T12:40:51Z")

</div>

I’m not sure what the `which` function returns. Maybe find indices of elements? Does this do what you want?

```julia
findall(in(B), A)

```

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [February 24, 2019, 12:54pm UTC](https://discourse.julialang.org/t/julia-equivalent-to-r-in/21138/3 "2019-02-24T12:54:55Z")

</div>

It’s almost the same R’s `which` returns only the indec of positions that are true

---

<div class="post-metadata">

**Author:** ![Graham\_W\_Griffiths](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Graham\_W\_Griffiths](https://discourse.julialang.org/u/Graham_W_Griffiths)\
**Post date:** [February 24, 2019, 1:13pm UTC](https://discourse.julialang.org/t/julia-equivalent-to-r-in/21138/4 "2019-02-24T13:13:47Z")

</div>

That worked fine.

Many thanks
