R/monitor_slice.R
monitor_slice.Rd
An mts_monitor object is reduced so as to contain only
the first or last n
timeseries. These functions work similarly to
dplyr::slice_head
and
dplyr::slice_tail
but apply to both dataframes in the mts_monitor object.
This is primarily useful when the mts_monitor object has been ordered
by a previous call to monitor_arrange
or by some other means.
monitor_slice_head()
selects the first and monitor_slice_tail()
the last timeseries in the object.
monitor_slice_head(monitor, n = 5)
monitor_slice_tail(monitor, n = 5)
mts_monitor object.
Number of rows of monitor$meta
to select.
A subset of the incoming mts_monitor time series object.
(A list with meta
and data
dataframes.)
library(AirMonitor)
# Find lowest elevation sites
Camp_Fire %>%
monitor_filter(!is.na(elevation)) %>%
monitor_arrange(elevation) %>%
monitor_slice_head(n = 5) %>%
monitor_getMeta() %>%
dplyr::select(elevation, locationName)
#> # A tibble: 5 × 2
#> elevation locationName
#> <dbl> <chr>
#> 1 0.9 San Rafael
#> 2 0.9 Redwood City
#> 3 1.5 San Francisco
#> 4 2.21 Calexico - Ethel Street
#> 5 2.7 Oakland West
# Find highest elevation sites
Camp_Fire %>%
monitor_filterMeta(!is.na(elevation)) %>%
monitor_arrange(elevation) %>%
monitor_slice_tail(n = 5) %>%
monitor_getMeta() %>%
dplyr::select(elevation, locationName)
#> # A tibble: 5 × 2
#> elevation locationName
#> <dbl> <chr>
#> 1 1917. Tahoe City
#> 2 2055. Lee Vining
#> 3 2291 MMNPS1033
#> 4 2306. Devil's Postpile
#> 5 2646. MMFS10401