mts_selectWhere {MazamaTimeSeries}R Documentation

Data-based subsetting of time series within an mts object.

Description

Subsetting of mts acts similarly to tidyselect::where() working on mts$data. The returned mts object will contain only those time series where FUN applied to the time series data returns TRUE.

Usage

mts_selectWhere(mts, FUN)

Arguments

mts

mts object.

FUN

A function applied to time series data that returns TRUE or FALSE.

Value

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

See Also

mts_select

Examples

library(MazamaTimeSeries)

# Show all Camp_Fire locations
Camp_Fire$meta$locationName

# Set a threshold
threshold <- 500

# Find time series with data at or above this threshold
worst_sites <-
  Camp_Fire %>%
  mts_selectWhere(
    function(x) { any(x >= threshold, na.rm = TRUE) }
  )

# Show the worst locations
worst_sites$meta$locationName


[Package MazamaTimeSeries version 0.3.0 Index]