A generalized data filter for mts objects to choose rows/cases where conditions are true. Multiple conditions may be 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.

mts_filterData(mts, ...)

Arguments

mts

mts object.

...

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

Value

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

Note

Filtering is done on variables in mts$data and results in an incomplete and irregular time axis.

See also

Examples

library(MazamaTimeSeries)

# Are there any times when data exceeded 150?
sapply(example_mts$data, function(x) { any(x > 150, na.rm = TRUE) })
#>               datetime  4af81ed0f6ec7acd_4734  c3ac53faf335f19f_5030 
#>                   TRUE                  FALSE                  FALSE 
#> 776e00b070251a36_23237  ec61b544c1dbfe21_2448  70e599f772b22877_4670 
#>                  FALSE                  FALSE                   TRUE 
#>  e0d610f7f219e39f_5080  2ee691d37eaa1aff_3529  ecd1d2c35c1c18cf_3505 
#>                  FALSE                  FALSE                  FALSE 
#>  05533d5b998ac7bf_3525  91299b887fface5f_3515  c316bcf7a85c8242_3617 
#>                  FALSE                  FALSE                   TRUE 
#>  a812772f2ef60b6f_3527  70f70265dbeb7f36_3551  f1eb28176ffa3c00_3487 
#>                  FALSE                   TRUE                   TRUE 
#>  28a43b2d6854838f_4725  da4cadd2d6ea5302_4686  d68d5d33331df58f_4689 
#>                  FALSE                   TRUE                   TRUE 
#>  2de587fc7359dd00_4662  07702ba2209dec22_4702  1fb48f53c052893a_4692 
#>                  FALSE                  FALSE                   TRUE 
#>  ada194ce98ce4bed_5184  a3eb0d42e5c78f8b_5228  065b6608aa9e6136_5218 
#>                  FALSE                  FALSE                  FALSE 
#>  36fa039140645de8_2504  173ff64a55da1183_2693  055497925c615bbd_2452 
#>                   TRUE                   TRUE                  FALSE 
#>  6db0b260ed58bea0_2713  8d9ad84c05e66fcb_2496  30b3a848f934811d_4746 
#>                   TRUE                   TRUE                  FALSE 
#>  bf7350cd6c2ec4c1_4727 452fd84452485d47_23233 bde3b79da492ff98_23429 
#>                  FALSE                   TRUE                  FALSE 
#> 76a49e0074377eb5_23427 8c345724ee28a6ef_23253 85a2219173d7e0e6_22695 
#>                   TRUE                   TRUE                  FALSE 
#> f4b229bfc8882d90_22687 dfed9bdf5bbdeee0_23093 d76f0e830185fe4c_23291 
#>                  FALSE                  FALSE                  FALSE 

# Show all times where da4cadd2d6ea5302_4686 > 150
example_mts %>%
  mts_filterData(da4cadd2d6ea5302_4686 > 150) %>%
  mts_extractData() %>%
  dplyr::pull(datetime)
#> [1] "2019-07-05 04:00:00 UTC" "2019-07-05 05:00:00 UTC"