# What is julia lang equivalent to R's %in%?

**URL:** https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314
**Category:** New to Julia
**Created:** [March 2, 2021, 9:52am UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314 "2021-03-02T09:52:08Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)
#### Post date: [March 2, 2021, 9:52am UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/1 "2021-03-02T09:52:09Z")

</div>

Hello, I have a vector:

```julia
b = ["NC_001422", "NZ_CP008698", "NZ_CP016318" , "NZ_CP010905", "NZ_CP019649",
         "NZ_CP029707" , "NZ_CP011102", "NC_006905", "NC_006905", 
         "NC_009142", "NC_006322", "NC_013971", "NC_017451", "NC_014494",
         "NC_017340", "NC_008024", "NC_011375", "NC_007296", "NC_008022",
         "NC_004070", "NC_003197", "NC_012225", "NC_011566", "NC_012751",
         "NC_005362", "NC_002976", "NC_026268", "NC_002737"]

```

I would like to test if the object “AC\_000006” is present in vector b. What would be Julia’s equivalent to R’s %in%?  
Thank you

---

<div class="post-metadata">

### Author: ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)
#### Post date: [March 2, 2021, 9:59am UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/2 "2021-03-02T09:59:54Z")

</div>

```julia
julia> "NC_011566" ∈ b
true

```

You have to type `\in` + tab to get ∈. Otherwise you can use `"NC_011566" in b` or `in("NC_011566", b)` (they are all the same thing).

---

<div class="post-metadata">

### Author: ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)
#### Post date: [March 2, 2021, 10:06am UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/3 "2021-03-02T10:06:15Z")

</div>

Thanks

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [March 2, 2021, 1:23pm UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/4 "2021-03-02T13:23:17Z")

</div>

No need to reach for unicode in this particular case:

```julia
julia> "NC_011566" in b
true

```

As with all operators, though, you can also just call it as a normal function:

```julia
julia> in("NC_011566", b)
true

```

Unlike R, there’s not a general mechanism for putting an arbitrary function in infix position, and this is the only “word” that works like this. All other infix operations are symbols of some sort — which you can define and use yourself.

---

<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: [March 2, 2021, 1:31pm UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/5 "2021-03-02T13:31:24Z")

</div>

> [@mbauman](#):
>
> this is the only “word” that works like this.

```julia
jl> 3 isa Int
true

```

😉

This is not a generic function, though.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [March 2, 2021, 1:35pm UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/6 "2021-03-02T13:35:38Z")

</div>

Ah, thanks. I knew as I was writing that sentence that I was likely to be wrong. If I were feeling snarky I’d say that “isa” isn’t a (dictionary) word! 😛

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [March 2, 2021, 1:42pm UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/7 "2021-03-02T13:42:55Z")

</div>

> [@mbauman](#):
>
> Unlike R, there’s not a general mechanism for putting an arbitrary function in infix position

You could resurrect [GitHub - Ismael-VC/InfixFunctions.jl: Julia infix function hack.](https://github.com/SalchiPapa/InfixFunctions.jl)

---

<div class="post-metadata">

### Author: ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)
#### Post date: [March 2, 2021, 1:54pm UTC](https://discourse.julialang.org/t/what-is-julia-lang-equivalent-to-rs-in/56314/8 "2021-03-02T13:54:21Z")

</div>

But `where` certainly is 😉
