# DataFramesMeta: @rsubset or condition?

**URL:** <https://discourse.julialang.org/t/dataframesmeta-rsubset-or-condition/121763>\
**Category:** New to Julia\
**Tags:** dataframes, dataframesmeta\
**Created:** [October 25, 2024, 8:51pm UTC](https://discourse.julialang.org/t/dataframesmeta-rsubset-or-condition/121763 "2024-10-25T20:51:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alecStewart1](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@alecStewart1](https://discourse.julialang.org/u/alecStewart1)\
**Post date:** [October 25, 2024, 8:51pm UTC](https://discourse.julialang.org/t/dataframesmeta-rsubset-or-condition/121763/1 "2024-10-25T20:51:40Z")

</div>

Say I have some dataframe where I want to select items by one condition or another that’s a combination.

```julia
@rsubset df :x == 1 || :x == 2 :y == 3

```

With the data I’m working with, this returns matches of the 2nd clause and not the first. Is this possible, or do I have to just use `filter`?

```julia
filter(d -> d.x == 1 || d.x == 2 && d.y == 3, df)

```

---

<div class="post-metadata">

**Author:** ![bertschi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bertschi/32/33462_2.png) [@bertschi](https://discourse.julialang.org/u/bertschi)\
**Post date:** [October 25, 2024, 10:03pm UTC](https://discourse.julialang.org/t/dataframesmeta-rsubset-or-condition/121763/2 "2024-10-25T22:03:16Z")

</div>

You are missing `&&` in your condition, i.e.,

```julia
@rsubset df :x == 1 || :x == 2 :y == 3
# parses as
@rsubset(df, :x == 1 || :x == 2, :y == 3)
# which is the same as
@rsubset df ((:x == 1 || :x == 2) && :y == 3)
# as multiple conditions get combined via `and`

# In contrast
@rsubset df :x == 1 || :x == 2 && :y == 3
# parses as
@rsubset(df, (:x == 1 || (:x == 2 && :y == 3)))
# and gives the same result as
filter(d -> d.x == 1 || d.x == 2 && d.y == 3, df)

```

---

<div class="post-metadata">

**Author:** ![alecStewart1](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@alecStewart1](https://discourse.julialang.org/u/alecStewart1)\
**Post date:** [October 25, 2024, 10:39pm UTC](https://discourse.julialang.org/t/dataframesmeta-rsubset-or-condition/121763/3 "2024-10-25T22:39:08Z")

</div>

_sigh_ Well, I feel stupid.
