A generalized data filter for pat objects to choose rows/cases where conditions are true. Multiple conditions are combined with & or separated by a comma. Only rows where the condition evaluates to TRUE are kept. Rows where the condition evaluates to NA are dropped.

If an empty pat object is passed in, it is immediately returned, allowing for multiple filtering steps to be piped together and only checking for an empty pat object at the end of the pipeline.

pat_filter(pat, ...)

Arguments

pat

pat object.

...

Logical predicates defined in terms of the variables in pat$data.

Value

A subset of the incoming pat time series object. (A list with meta and data dataframes.)

Note

Filtering is done on values in pat$data.

Examples


library(AirSensor2)

# Unhealthy values
example_pat %>%
  pat_filter(pm2.5_atm_a > 55.5, pm2.5_atm_b > 55.5) %>%
  pat_getData() %>%
  head()
#> # A tibble: 3 × 18
#>   datetime            sensor_index  rssi uptime pa_latency memory humidity
#>   <dttm>                     <dbl> <dbl>  <dbl>      <dbl>  <dbl>    <dbl>
#> 1 2023-01-02 02:48:00        76545   -68  15921        209  15728       65
#> 2 2023-01-02 02:50:01        76545   -68  16042        231  15560       64
#> 3 2023-01-02 02:52:01        76545   -71  16162        221  15560       64
#> # ℹ 11 more variables: temperature <dbl>, pressure <dbl>, pm2.5_alt <dbl>,
#> #   pm2.5_alt_a <dbl>, pm2.5_alt_b <dbl>, pm2.5_atm <dbl>, pm2.5_atm_a <dbl>,
#> #   pm2.5_atm_b <dbl>, pm2.5_cf_1 <dbl>, pm2.5_cf_1_a <dbl>, pm2.5_cf_1_b <dbl>