An mts 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 object.
This is primarily useful when the mts object has been ordered by a
previous call to mts_arrange
or by some other means.
slice_head()
selects the first and slice_tail()
the last timeseries
in the object.
mts_slice_head(mts, n = 5)
mts_slice_tail(mts, n = 5)
mts object.
Number of rows of mts$meta
to select.
A subset of the incoming mts time series object.
(A list with meta
and data
dataframes.)
library(MazamaTimeSeries)
# Find lowest elevation sites
Camp_Fire %>%
mts_filterMeta(!is.na(elevation)) %>%
mts_arrange(elevation) %>%
mts_slice_head(n = 5) %>%
mts_extractMeta() %>%
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 %>%
mts_filterMeta(!is.na(elevation)) %>%
mts_arrange(elevation) %>%
mts_slice_tail(n = 5) %>%
mts_extractMeta() %>%
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