mts_slice_head {MazamaTimeSeries} | R Documentation |
Subset time series based on their position
Description
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.
Usage
mts_slice_head(mts, n = 5)
mts_slice_tail(mts, n = 5)
Arguments
mts |
mts object. |
n |
Number of rows of |
Value
A subset of the incoming mts time series object.
(A list with meta
and data
dataframes.)
Examples
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)
# 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)
[Package MazamaTimeSeries version 0.3.0 Index]