Learn R Programming

MazamaTimeSeries (version 0.3.0)

mts_selectWhere: 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)

Value

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

Arguments

mts

mts object.

FUN

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

See Also

mts_select

Examples

Run this code
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

Run the code above in your browser using DataLab