R/pat_filter.R
pat_filter.Rd
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.
pat_filter(pat, ...)
PurpleAir Timeseries pat object.
Logical predicates defined in terms of the variables in the
pat$data
.
A subset of the incoming pat
.
library(AirSensor)
unhealthy <- pat_filter(example_pat, pm25_A > 55.5, pm25_B > 55.5)
head(unhealthy$data)
#> # A tibble: 6 × 21
#> datetime sensor_index rssi uptime pa_latency memory humidity
#> <dttm> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 2022-07-05 03:45:46 3515 -78 9019 653 15168 77
#> 2 2022-07-05 03:49:46 3515 -79 9259 576 15872 78
#> 3 2022-07-05 04:07:59 3515 -78 10342 368 14872 80
#> 4 2022-07-05 04:09:46 3515 -77 10459 3203 15168 80
#> 5 2022-07-05 04:11:47 3515 -78 10579 331 15168 80
#> 6 2022-07-05 04:13:48 3515 -79 10699 311 15168 81
#> # ℹ 14 more variables: temperature <dbl>, pressure <dbl>, pm1_atm_A <dbl>,
#> # pm1_atm_B <dbl>, pm25_atm_A <dbl>, pm25_atm_B <dbl>, pm10_atm_A <dbl>,
#> # pm10_atm_B <dbl>, pm25_A <dbl>, pm25_B <dbl>, adc0 <dbl>, bsec_iaq <dbl>,
#> # datetime_A <dttm>, datetime_B <dttm>