Filter() on several columns at the same time

Hi,
I have a df like this one and I would like to do a multiple filter on this. I need to select my Env data per station but also per a specific depth.
Like I want to filter to have the Env data for the station 1 but only at 250m, the station 2 I want the Env data at 190m etc.
How can I do this "multiple filter"


Thanks
Station   Depth Env1  Env2  Env3
1           100 (numeric data)
1           250 (numeric data)
2           280 (numeric data)
2           190 (numeric data)
2           360 (numeric data)
3           155 (numeric data)
3           580 (numeric data)

in R you can combine logical statements with

  • and &
  • or |

operators
i.e.

( new <- old |> filter((Station == 1 & Depth == 250) |
                       (Station == 2 & Depth == 190)) )

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.